14

I'm transitioning an application to iOS 7 which has been fairly smooth, there's one thing I cannot figure out.

I have a view controller with a couple buttons that I display with a UIPopoverController.

It looks to me like the popover controller is doing something to clip the content of it's view controller to be rounded.

iOS6 (I want this):

enter image description here

iOS7 (something changed):

enter image description here

I'm using custom popover controller background class described here http://blog.teamtreehouse.com/customizing-the-design-of-uipopovercontroller

Here's my specific version of that background class http://pastebin.com/fuNjBqwU

Does anyone have any idea what to change to get it back to my iOS 6 look?

yizzlez
  • 8,757
  • 4
  • 29
  • 44
gngrwzrd
  • 5,902
  • 4
  • 43
  • 56

3 Answers3

32

In popover content controller:

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    self.view.superview.layer.cornerRadius = 0;
}
OneSman7
  • 404
  • 4
  • 4
  • This works. I load a subclassed UINavigationController in my Popover style Storyboard Segue with this solution implemented in my subclass, and I no longer have the interior rounded corners. – Phil Dec 30 '13 at 23:01
  • 3
    Thanks! Just in case someone else has the same problem as me, I wanted to add that if you're contentView is in a navigationController, you need to adjust to this: `self.navigationController.view.superview.layer.cornerRadius = 0;` – Logan Aug 18 '14 at 19:41
7

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;
            }
        }
    }
}
u10int
  • 219
  • 2
  • 8
  • The while may fail in case there is no superview of view. Put "view = view.superview" after "if". – Misha Jun 08 '14 at 14:29
1

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.

jankins
  • 670
  • 5
  • 16