3

I built a custom Popoverview, but fail to remove the content's rounded corners.

Tried to set .layer.cornerRadius = 0.0 in almost every view in found, with no success.

Image Link: Custom Popover

Red border is of UIViewController used to init the UIPopoverController with, green is background of custom UIPopoverBackgroundView.

5

1 Answer 1

7

Answer from this thread: UIView default styling has rounded corners?

There is no supported way to make the view inside of your UIPopoverController not have rounded corners. The internal code of the UIPopoverController adds your view to a view with rounded corners that clips to bounds.

There may be a hackish way to do it, i.e. waiting until the UIPopoverController is shown and then traversing through all of the parent's of your view and setting them all to have cornerRadius = 0; and clipsToBounds = NO;, but even if you find a solution it might not be compatible with all versions of iOS and if Apple changes some internal code of UIPopoverController in the future then your solution could break.

If you really want to do this then the best way to go is to create your own class that mimics the UIPopoverController functionality.

6
  • have tried this once with no success, but will try again
    – Kalle
    Commented Mar 28, 2014 at 11:10
  • Well, you can always create your own view and add the needed functionality to it.
    – Lord Zsolt
    Commented Mar 28, 2014 at 11:18
  • 3
    finally got it to work, built a Custom UIPopoverController with it's own .presentPopoverFromRect method that calls [super presentPopoverFromRect:] and then set self.myViewController.view.superview.layer.cornerRadius = 0.0; clipsToBounds=NO seems not to be needed
    – Kalle
    Commented Mar 28, 2014 at 11:23
  • @Michael Where did you add the corner radius code to? Commented Aug 19, 2014 at 17:36
  • @KyleBegeman in customized UIPopoverController Class method - (void)presentPopoverFromRect:(CGRect)rect inView:(UIView *)view permittedArrowDirections:(UIPopoverArrowDirection)arrowDirections animated:(BOOL)animated
    – Kalle
    Commented Aug 22, 2014 at 14:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.