Giving UIView rounded corners

Try this

#import <QuartzCore/QuartzCore.h> // not necessary for 10 years now  :)

view.layer.cornerRadius = 5;
view.layer.masksToBounds = true;

Note: If you are trying to apply rounded corners to a UIViewController‘s view, it should not be applied in the view controller’s constructor, but rather in -viewDidLoad, after view is actually instantiated.

Leave a Comment