Skip to content

Instantly share code, notes, and snippets.

@filsv
Last active March 16, 2017 10:21
Show Gist options
  • Save filsv/5c309beb6b041f03cc35311f85a20cdd to your computer and use it in GitHub Desktop.
Save filsv/5c309beb6b041f03cc35311f85a20cdd to your computer and use it in GitHub Desktop.
Apply round corner/s on UIView, you can apply round corner to any side of UIView
func roundCorners(corners: UIRectCorner, radius: CGFloat)
{
let size = CGSize(width: radius, height: radius)
let path = UIBezierPath(roundedRect: self.bounds, byRoundingCorners: corners, cornerRadii: size)
let mask = CAShapeLayer()
mask.path = path.cgPath
self.layer.mask = mask
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment