// 用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];
文章標籤
全站熱搜