Dashed line border around UIView

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

How do I add dashed line border around UIView.

Something Like this

\"\"

23条回答
  •  不知归路
    2020-12-02 04:33

    For this you need add CAShapeLayer for that particular object

     CAShapeLayer * dotborder = [CAShapeLayer layer];
        dotborder.strokeColor = [UIColor redColor].CGColor;//your own color
        dotborder.fillColor = nil;
        dotborder.lineDashPattern = @[@4, @2];//your own patten 
        [codeBtn.layer addSublayer:dotborder];
        dotborder.path = [UIBezierPath bezierPathWithRect:codeBtn.bounds].CGPath;
        dotborder.frame = codeBtn.bounds;
    

提交回复
热议问题