Last active
January 5, 2018 09:44
-
-
Save mteera/f83b0648802e706bcd280e3cc9548b2c to your computer and use it in GitHub Desktop.
An extension to create rounded corners on particular edges.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
extension UIView { | |
func roundCorners(_ corners: UIRectCorner, radius: CGFloat) { | |
let path = UIBezierPath(roundedRect: self.bounds, byRoundingCorners: corners, cornerRadii: CGSize(width: radius, height: radius)) | |
let mask = CAShapeLayer() | |
mask.path = path.cgPath | |
self.layer.mask = mask | |
} | |
// Usage: view.roundCorners([.bottomRight, .topRight], radius: 5) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment