Last active
February 11, 2017 07:31
-
-
Save artemnovichkov/195492c90a4153a7df2d679eb2ccd0b3 to your computer and use it in GitHub Desktop.
Extension for rounded corners in UIView. Warning: make sure that your UIView already has correct frame.
This file contains 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 round(with radius: CGFloat, corners: UIRectCorner) { | |
let roundedPath = UIBezierPath(roundedRect: bounds, | |
byRoundingCorners: corners, | |
cornerRadii: CGSize(width: radius, height: radius)) | |
let maskLayer = CAShapeLayer() | |
maskLayer.path = roundedPath.cgPath | |
layer.mask = maskLayer | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment