删除 UIPopoverController 的边框

发布于 2024-10-12 05:29:23 字数 207 浏览 9 评论 0原文

我有一个要求,我必须为 UIPopoverController 的弹出视图显示自定义边框,而不是默认的“黑色主题”边框。是否可以?

我无法使用默认的黑色边框,因为它不适合应用程序的颜色主题。

SDK 中没有提供执行此操作的规定。我也用谷歌搜索看看其他人是否遇到过这个问题以及他们是否已经解决了它,但没有运气!

等待建议。

谢谢, 拉杰

I have a requirement where in I have to display a custom border for UIPopoverController's popover view instead of the default "Black theme" border. Is it possible?

I cannot use the default black border because it doesnt suite the application's color theme.

There is no provision in the SDK to do this. I have also googled to see if someone else have faced this problem and if they have solved it, but with no luck!

Awaiting suggestions.

Thanks,
Raj

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

〃安静 2024-10-19 05:29:23

通过使用 UIView 以及覆盖主 rootViewController 视图中的 hitTest 来查看触摸点是否在该视图之外解决了这个问题。如果是,则将使用该事件来关闭新的弹出窗口,否则该事件将被转发到新的弹出窗口。

Solved this by using UIView and also by overriding the hitTest in the main rootViewController's view to see if the touch point is outside that view. If so, the event will be consumed to dismiss the new popover, otherwise the event will be forwarded to the new popover.

节枝 2024-10-19 05:29:23

添加popview作为子视图,代码是:

//!you must define the dimBackgroundView and set view in head file firstly, 

//action for a button,to add set view as a subview
 - (IBAction)openSetting:(id)sender {

    if(!dimBackgroundView)
    {
       dimBackgroundView = [[UIView alloc] initWithFrame:self.view.bounds];
    }
    dimBackgroundView.backgroundColor = [[UIColor clearColor] colorWithAlphaComponent:0.0];

    [self.view addSubview:dimBackgroundView];

    SettingViewController *set = [[SettingViewController alloc]initWithNibName:nil bundle:nil];
    [set.view setFrame:CGRectMake(120, 50, 400, 600)];
    self.setView = set;

    //add shadow
    set.view.layer.shadowOffset = CGSizeMake(3, 3);
    set.view.layer.shadowColor = [UIColor colorWithRed:70.0/255.0 green:70.0/255.0 blue:80.0/255.0 alpha:1.0].CGColor;
    set.view.layer.shadowOpacity = 0.8;

    [self.view addSubview:set.view];
}
//check touch position, if touch position is outside of setview, remove it from superview
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *) event{
    UITouch *touch = [[event allTouches] anyObject];
    if ([self.setView.view superview] && self.dimBackgroundView == touch.view) {
        [self.dimBackgroundView removeFromSuperview];
        [self.setView.view removeFromSuperview];
    }
}

add popview as subview, code is:

//!you must define the dimBackgroundView and set view in head file firstly, 

//action for a button,to add set view as a subview
 - (IBAction)openSetting:(id)sender {

    if(!dimBackgroundView)
    {
       dimBackgroundView = [[UIView alloc] initWithFrame:self.view.bounds];
    }
    dimBackgroundView.backgroundColor = [[UIColor clearColor] colorWithAlphaComponent:0.0];

    [self.view addSubview:dimBackgroundView];

    SettingViewController *set = [[SettingViewController alloc]initWithNibName:nil bundle:nil];
    [set.view setFrame:CGRectMake(120, 50, 400, 600)];
    self.setView = set;

    //add shadow
    set.view.layer.shadowOffset = CGSizeMake(3, 3);
    set.view.layer.shadowColor = [UIColor colorWithRed:70.0/255.0 green:70.0/255.0 blue:80.0/255.0 alpha:1.0].CGColor;
    set.view.layer.shadowOpacity = 0.8;

    [self.view addSubview:set.view];
}
//check touch position, if touch position is outside of setview, remove it from superview
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *) event{
    UITouch *touch = [[event allTouches] anyObject];
    if ([self.setView.view superview] && self.dimBackgroundView == touch.view) {
        [self.dimBackgroundView removeFromSuperview];
        [self.setView.view removeFromSuperview];
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文