UIBezierPath貝塞爾曲線的常用方法總結


1、根據一個矩形畫曲線

+ (UIBezierPath *)bezierPathWithRect:(CGRect)rect

 

2、根據矩形框的內切圓畫曲線

+ (UIBezierPath *)bezierPathWithOvalInRect:(CGRect)rect

 

3、根據矩形畫帶圓角的曲線

+ (UIBezierPath *)bezierPathWithRoundedRect:(CGRect)rect cornerRadius:(CGFloat)cornerRadius

 

4、在矩形中,可以針對四角中的某個角加圓角, 一般用於設置某個視圖的頂端兩角為圓形

+ (UIBezierPath *)bezierPathWithRoundedRect:(CGRect)rect byRoundingCorners:(UIRectCorner)corners cornerRadii:(CGSize)cornerRadii

參數:

corners:枚舉值,可以選擇某個角

cornerRadii:圓角的大小

 
5、以某個中心點畫弧線 
 + ( UIBezierPath *)bezierPathWithArcCenter:( CGPoint)center radius:( CGFloat)radius startAngle:( CGFloat)startAngle endAngle:( CGFloat)endAngle clockwise:( BOOL)clockwise;

參數:

center:弧線中心點的坐標

radius:弧線所在圓的半徑

startAngle:弧線開始的角度值

endAngle:弧線結束的角度值

clockwise:是否順時針畫弧線

 

6、畫二元曲線,一般和moveToPoint配合使用

- (void)addQuadCurveToPoint:(CGPoint)endPoint controlPoint:(CGPoint)controlPoint

參數:

endPoint:曲線的終點

controlPoint:畫曲線的基准點

 

7、以三個點畫一段曲線,一般和moveToPoint配合使用

- (void)addCurveToPoint:(CGPoint)endPoint controlPoint1:(CGPoint)controlPoint1 controlPoint2:(CGPoint)controlPoint2

參數:

endPoint:曲線的終點

controlPoint1:畫曲線的第一個基准點

controlPoint2:畫曲線的第二個基准點


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM