Search code examples
iosswiftuiviewcornerradius

Change cornerRadius of the modal view controller


My goal is to increase corner radius of the modally presented controller to 25. As you can see in the picture it has rounded corners by default but I need them to have greater radius. I've tried rounding corners by accessing controllers view, but it's not working.

view.layer.cornerRadius = 25

I haven't found any mention of it in the apple documentation, is there any way to make it work? Is this even possible?

enter image description here


Solution

  • you can't, that's a custom presentation controller created by apple that is a protected/private API to conform to new design standards throughout the apple eco system for ios 13 and beyond. what you can do instead is create your own subclass implementation of UIPresentationController and then round the corners to whatever corner radius you wish. subclassing UIPresentationController with pan gestures that interact well with even first degree nesting of scroll views is a daunting task, however. I'd check out some example code for this before you try to override the default since doing so will land you in a black hole of chaos pretty quickly unless you're well versed in UIKit, Foundation, and delegation with ios.