Dashed line border around UIView

后端 未结 23 2342
粉色の甜心
粉色の甜心 2020-12-02 04:16

How do I add dashed line border around UIView.

Something Like this

\"\"

23条回答
  •  既然无缘
    2020-12-02 04:38

    In Swift 3

    let border = CAShapeLayer();
    border.strokeColor = UIColor.black.cgColor;
    border.fillColor = nil;
    border.lineDashPattern = [4, 4];
    border.path = UIBezierPath(rect: theView.bounds).cgPath
    border.frame = theView.bounds;
    theView.layer.addSublayer(border);
    

提交回复
热议问题