I have a rounded UIView
and I have added a dashed line stroke to it.
,,,
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)
But view.cornerRadius
is not working as expected:
Corner is wiped out.