0

I want to change the corner radius of Popoverview.

Below is my code.

class PopOverViewController: UIViewController {
   override func viewDidLoad() {
      super.viewDidLoad()
   }

   override func viewWillLayoutSubviews() {
         super.viewDidLayoutSubviews()
         self.view.superview?.layer.cornerRadius = 0.0
         self.view.superview?.layer.masksToBounds = true
    }
}

I am presenting the view controller like below

if let popoverPresentationController = popOverViewController.popoverPresentationController {
            popoverPresentationController.permittedArrowDirections = .down
            popoverPresentationController.sourceView = tabBar
            popoverPresentationController.sourceRect = rect
            popoverPresentationController.delegate = self
            popoverPresentationController.canOverlapSourceViewRect = false
            popOverViewController.preferredContentSize = CGSize(width: 341, height: 68)
            self.present(popOverViewController, animated: true, completion: {
            })
        }

It always shows rounded corners.

Any help is appreciated.

Badrinath
  • 325
  • 1
  • 7
  • 25
  • I tried changing the corner radius in `viewDidAppear ` , `viewWillAppear` , still no luck. – Badrinath Jul 19 '19 at 00:01
  • Possible duplicate of [How to remove rounded corners in PopoverView?](https://stackoverflow.com/questions/22710213/how-to-remove-rounded-corners-in-popoverview) – Olympiloutre Jul 19 '19 at 00:10

1 Answers1

0

As of right now, there is no supported way to have a popover view controller with unrounded corners. The way that UIPopoverController works is by adding your view to a view with rounded corners that clips to bounds.

There are two ways to go around this:

  1. Wait for popover controller to be shown then traverse its parents and set radius to 0 and clips to bounds to false. This is kind of hacky and it it might not be compatible with all versions of iOS past and future. I do not recommend this.
  2. Create your own class that mimics the same functionality as UIPopoverController. This is the best way to solve your problem.
Wizard-of-Koz
  • 1,217
  • 1
  • 10
  • 13