// 用UIBezierPath 畫一個長方形, 你可自行更改坐標

UIBezierPath *path =  [UIBezierPath bezierPathWithRoundedRect:btnView.bounds  byRoundingCorners:UIRectCornerAllCorners  

cornerRadii:radius];    

 

// 用CAShapeLayer包裹

UIBezierPath:  

CAShapeLayer *shapeLayer = [CAShapeLayer layer];  

shapeLayer.path = [path CGPath];  

shapeLayer.strokeColor = [[UIColor blueColor] CGColor];  

shapeLayer.lineWidth = 3.0;  

shapeLayer.fillColor = [[UIColor clearColor] CGColor];

// 把CAShapeLayer加到你的View中  

[self.view.layer addSublayer:shapeLayer];  

arrow
arrow
    文章標籤
    UIBezierPath iOS Objective-C
    全站熱搜
    創作者介紹
    創作者 Mr.Lin 的頭像
    Mr.Lin

    Mr.Lin

    Mr.Lin 發表在 痞客邦 留言(0) 人氣()