How to set corner radius only only bottom-left,bottom-right and top-left corner textview?
let rectShape = CAShapeLayer()
rectShape.backgroundColor = UICo
Swift 4+
func roundCorners(with CACornerMask: CACornerMask, radius: CGFloat) {
self.layer.cornerRadius = radius
self.layer.maskedCorners = [CACornerMask]
}
Top right
roundCorners(with: [.layerMinXMinYCorner], radius: 20)
Top left
roundCorners(with: [.layerMaxXMinYCorner], radius: 20)
Bottom right
roundCorners(with: [.layerMinXMaxYCorner], radius: 20)
Bottom left
roundCorners(with: [.layerMaxXMaxYCorner], radius: 20)
Multiple corners at the same time
func roundedCorners(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
layer.mask = mask
}
How to use
roundedCorners(corners: [.topLeft, .topRight], radius: 20)