我有一个圆形,UIView并在其中添加了一条虚线描边。
,,,
var view = CAShapeLayer()
view.strokeColor = UIColor.red.cgColor
view.lineDashPattern = [2, 2]
view.frame = addphotoView.bounds
view.fillColor = nil
view.path = UIBezierPath(rect: addphotoView.bounds).cgPath
view.cornerRadius = 16
view.masksToBounds = true
addphotoView.layer.addSublayer(yourViewBorder)
Run Code Online (Sandbox Code Playgroud)
角落被抹去。