Skip to content

Instantly share code, notes, and snippets.

@mansi-27
Created February 22, 2018 18:00
Show Gist options
  • Save mansi-27/76db322acbba5970eb3cd4ea3c69630f to your computer and use it in GitHub Desktop.
Save mansi-27/76db322acbba5970eb3cd4ea3c69630f to your computer and use it in GitHub Desktop.
Sets rounded corners to the UIView
extension UIView {
/// Sets rounded corners to the UIView
func roundedCorners(radius: CGFloat? = nil) {
if let radius = radius {
layer.cornerRadius = radius
} else {
layer.cornerRadius = frame.size.height / 2
}
clipsToBounds = true
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment