需要帮助贴合标签,以便填充左侧和右侧。代码在底部。
@IBOutlet weak var header: UILabel!
override func viewDidLoad() {
header.adjustsFontSizeToFitWidth = true
let rectShape = CAShapeLayer()
rectShape.bounds = self.header.frame
rectShape.position = self.header.center
rectShape.path = UIBezierPath(roundedRect: self.header.bounds, byRoundingCorners: [.bottomLeft , .bottomRight], cornerRadii: CGSize(width:300, height: 200)).cgPath
self.header.layer.backgroundColor = UIColor.green.cgColor
//Here I'm masking the textView's layer with rectShape layer
self.header.layer.mask = rectShape
super.viewDidLoad()