how to set cornerRadius for only bottom-left,bottom-right and top-left corner textview?

前端 未结 12 908
名媛妹妹
名媛妹妹 2020-11-27 12:50

How to set corner radius only only bottom-left,bottom-right and top-left corner textview?

let rectShape = CAShapeLayer()
    rectShape.backgroundColor = UICo         


        
12条回答
  •  悲&欢浪女
    2020-11-27 13:09

    Here is an extension for iOS 11+

     import Foundation
     import UIKit
    
     extension UIView {
    
       func roundCorners(_ corners: CACornerMask, radius: CGFloat, borderColor: UIColor, borderWidth: CGFloat) {
           self.layer.maskedCorners = corners
           self.layer.cornerRadius = radius
           self.layer.borderWidth = borderWidth
           self.layer.borderColor = borderColor.cgColor
    
       }
    
     }
    

    Usage:-

    self.yourView.roundCorners([.layerMaxXMaxYCorner, .layerMaxXMinYCorner], radius: 20.0, borderColor: UIColor.green, borderWidth: 1)
    

提交回复
热议问题