button corner radius swift code example
Example 1: add top corner radius swift
extension UIView {
func roundCorners(corners: UIRectCorner, radius: CGFloat) {
let path = UIBezierPath(roundedRect: bounds, byRoundingCorners: corners, cornerRadii: CGSize(width: radius, height: radius))
let mask = CAShapeLayer()
mask.path = path.cgPath
layer.mask = mask
}
}
Example 2: add buton border swift
button.layer.borderWidth = 1
button.layer.borderColor = UIColor.black.cgColor
Example 3: add corner radius to uiview swift
view.layer.cornerRadius = 25
view.layer.masksToBounds = true
Example 4: round courners of uibutton
yourButton.layer.cornerRadius = 10; // this value vary as per your desire
yourButton.clipsToBounds = YES;