I know I can round all four corners using:
myBtn.layer.cornerRadius = 8 myBtn.layer.masksToBounds = true
Since I only want to round two,
Use this Code,
let path = UIBezierPath(roundedRect:viewTo.bounds, byRoundingCorners:[.TopRight, .TopLeft], cornerRadii: CGSizeMake(20, 20)) let maskLayer = CAShapeLayer() maskLayer.path = path.CGPath viewTo.layer.mask = maskLayer
hope its helpful