2

I am using a UIPopoverController to display a UIView. The layout is somewhat similar to a UISplitViewController so it is very strange looking to have rounded corners on the "detail view" because it leaves a small gap. I have not been able to find anything at all relating to other people having this problem, but these rounded corners seem to be the default style. Is it possible to remove them?

Things that might help:

  • I load my view from a nib file, but I have currently made no changes to the default UIView
  • I tried setting clipsToBound = NO in viewDidLoad
  • I tried setting layer.cornerRadius = 0 in viewDidLoad

There also seems to be a shadow on the top part of the view, but it is hard to tell. Is there any way I can just get rid of all this default styling? I just want a blank square.

Alec
  • 1,646
  • 3
  • 19
  • 35
  • Any chance you can attach a screen shot? – AngeloS Jul 11 '12 at 19:53
  • Unfortunately, I probably should not. But about 10 minutes after I added this bounty I scrapped UIPopover altogether. It is just way too much trouble for functionality that I have already rewritten. After the fact, my guess is that the UIPopoverBackgroundView was clipping the corners of my `UIView`, even though I subclassed it and thought I had everything right. Oh well. – Alec Jul 11 '12 at 20:08

3 Answers3

11

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.

Michael Frederick
  • 16,664
  • 3
  • 43
  • 58
0

The black gradient color frame with rounded corner is default for UIPopoverController. However you can use a custom class to set the background view . Here try following link.

change color navigation controller in a popover

Community
  • 1
  • 1
Ankit
  • 1,684
  • 14
  • 14
  • I already subclass `UIPopoverBackgroundView.` The view with rounded corners is not the frame for the popover, but the `UIView` that I display inside the popover. – Alec Jul 10 '12 at 14:17
0

For anyone who uses UIPopoverPresentationController, the following should work.

override open func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)

    view.superview?.layer.cornerRadius = 0
}
Lawliet
  • 3,438
  • 2
  • 17
  • 28