Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add a corner radius to a uiviewcontroller

I noticed that in snapchat they rounded their corners of a uiviewcontroller. I was wondering how could I replicate the same thing accross all view controllers. Would I declare it in the app delegate or in each individual view controller. Could someone please show me how to do it. I have an example image below. Look in the top corners of the view controller and you'll see that there rounded. I'm trying to replicate that.

example image

like image 857
Rosalind Avatar asked Oct 23 '25 21:10

Rosalind


1 Answers

You could use an extension, then you could apply a corner radius on any view, including the view controller's view. I haven't tried it though.

extension UIView {
    func makeCorner(withRadius radius: CGFloat) {
        self.layer.cornerRadius = radius
        self.layer.masksToBounds = true
        self.layer.isOpaque = false
    }
}

Usage:

myController.view.makeCorner(withRadius: 10.0)
like image 184
Frankie Avatar answered Oct 26 '25 10:10

Frankie