Xcode5 iOS7 - UIPopoverController Corner Radius

╄→гoц情女王★ 提交于 2019-12-03 23:49:57

I tried getting @OneSman7's solution to work, but the view with the cornerRadius wasn't the direct superview of the contentViewController.view instance. Instead, I had to walk up the view hierarchy searching for the one whose cornerRadius is no 0 and reset it (which is just a UIView instance, no special class name to check for). A less than ideal solution, but seems to work so far.

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];

    if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0")) {
        UIView *view = self.view;
        while (view != nil) {
            view = view.superview;
            if (view.layer.cornerRadius > 0) {
                view.layer.cornerRadius = 2.0;
                view = nil;
            }
        }
    }
}

In popover content controller:

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    self.view.superview.layer.cornerRadius = 0;
}

Perhaps you could just replace your background view's contentViewInsets with:

+ (UIEdgeInsets)contentViewInsets{
    return UIEdgeInsetsZero;
}

And then just give your contentViewController's view some extra padding on its edges, so that even though the corners will still be rounded, they won't contain any of your popover content so the rounding effect won't be visible.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!