UIBezierPath畫圓弧的記錄

2022-06-18 18:18:12 字數 796 閱讀 1610

uibezierpath通過

- (void)addarcwithcenter:(cgpoint)center radius:(cgfloat)radius startangle:(cgfloat)startangle endangle:(cgfloat)endangle clockwise:(bool)clockwise

可以畫出一段弧線。

看下各個引數的意義:

center:圓心的座標

radius:半徑

startangle:起始的弧度

endangle:圓弧結束的弧度

clockwise:yes為順時針,no為逆時針

方法裡面主要是理解startangle與endangle,剛開始我搞不清楚一段圓弧從哪算起始和終止,比如弧度為0的話,是從上下左右哪個點開始算

看了下面這張圖就明了了

看出0pi就是指圓最右邊開始計算的,順時針依次為m_pi/2,m_pi,m_pi*1.5

明白這個,用bezierpath畫圓弧就簡單了

比如要畫上圖加粗的那段就是:

[html]view plain

copy

uibezierpath *path = [[uibezierpath alloc] init];    

[path addarcwithcenter:center    

radius:radius    

startangle:m_pi*1.1    

endangle:m_pi*1.9    

clockwise:yes];  

UIBezierPath畫圓弧的記錄

uibezierpath通過 void addarcwithcenter cgpoint center radius cgfloat radius startangle cgfloat startangle endangle cgfloat endangle clockwise bool clock...

UIBezierPath 畫圓弧(角度問題)

uibezierpath通過 void addarcwithcenter cgpoint center radius cgfloat radius startangle cgfloat startangle endangle cgfloat endangle clockwise bool clock...

UIBezierPath畫圓弧的記錄

文中的圖很重要!根據下文,完成了下圖的mask 如下 cgsize size self.size 畫路徑 uibezierpath maskpath uibezierpath bezierpath bottom line maskpath movetopoint cgpointmake size.w...