參看放肆地使用UIBezierPath和CAShapeLayer畫各種圖形
參看使用CAShapeLayer與UIBezierPath可以實現不在view的drawRect方法中就畫出一些想要的圖形
CAShapeLayer 是 CALayer 的子類,但比 CALayer 更靈活,可以畫出各種圖形,當然,你也可以使用其他方式來畫,隨你。
<br />
使用CAShapeLayer與UIBezierPath可以實現不在view的drawRect方法中就畫出一些想要的圖形
步驟:
1、新建UIBezierPath對象bezierPath
2、新建CAShapeLayer對象caShapeLayer
3、將bezierPath的CGPath賦值給caShapeLayer的path,即caShapeLayer.path = bezierPath.CGPath
4、把caShapeLayer添加到某個顯示該圖形的layer中