首先說一下畫圓角吧,其實uibezierpath的畫角規則是這樣的:
**:
#import "viewcontroller.h"
@inte***ce
viewcontroller ()
@property (nonatomic, strong) cashapelayer *shapelayer;
@property (nonatomic, strong) uibezierpath *path;
@property (nonatomic, strong) uiview *maskview;
@end
@implementation
viewcontroller
- (cashapelayer *)shapelayer
return _shapelayer;
}//- (uibezierpath *)path
//#define degrees_to_radians(degrees) ((3.14159265359 * degrees) / 180)
- (void)viewdidload
其中
- (void)addarcwithcenter:(cgpoint)center radius:(cgfloat)radius startangle:(cgfloat)startangle endangle:(cgfloat)endangle clockwise:(bool)clockwise
其引數意義:
center:圓心的座標
radius:半徑
startangle:起始的弧度
endangle:圓弧結束的弧度
clockwise:yes為順時針,no為逆時針
初始化方法
+ (instancetype)bezierpath;
//建立乙個矩形
+ (instancetype)bezierpathwithrect:(cgrect)rect;
//建立圓形或者橢圓形
+ (instancetype)bezierpathwithovalinrect:(cgrect)rect;
//根據矩形畫帶圓角的曲線
+ (instancetype)bezierpathwithroundedrect:(cgrect)rect cornerradius:(cgfloat)cornerradius; // rounds all corners with the same horizontal and vertical radius
//在矩形中,可以針對四角中的某個角加圓角
+ (instancetype)bezierpathwithroundedrect:(cgrect)rect byroundingcorners:(uirectcorner)corners cornerradii:(cgsize)cornerradii;
/**引數:
corners:列舉值,可以選擇某個角
cornerradii:圓角的大小
*///以某個中心點畫弧線
+ (instancetype)bezierpathwitharccenter:(cgpoint)center radius:(cgfloat)radius startangle:(cgfloat)startangle endangle:(cgfloat)endangle clockwise:(bool)clockwise;
/**引數:
center:弧線中心點的座標
radius:弧線所在圓的半徑
startangle:弧線開始的角度值
endangle:弧線結束的角度值
clockwise:是否順時針畫弧線
*/// 根據cgpath建立並返回乙個新的uibezierpath物件
+ (instancetype)bezierpathwithcgpath:(cgpathref)cgpath;
//畫二元曲線,一般和movetopoint配合使用
- (void)addquadcurvetopoint:(cgpoint)endpoint controlpoint:(cgpoint)controlpoint
/**引數:
endpoint:曲線的終點
controlpoint:畫曲線的基準點
*///以三個點畫一段曲線,一般和movetopoint配合使用
- (void)addcurvetopoint:(cgpoint)endpoint controlpoint1:(cgpoint)controlpoint1 controlpoint2:(cgpoint)controlpoint2
/**引數:
endpoint:曲線的終點
controlpoint1:畫曲線的第乙個基準點
controlpoint2:畫曲線的第二個基準點
*/
基本用法:
//設定描繪的起點
- (void)movetopoint:(cgpoint)point;
//畫直線
- (void)addlinetopoint:(cgpoint)point;
//畫曲線,分別對應終點和兩個控制點
- (void)addcurvetopoint:(cgpoint)endpoint controlpoint1:(cgpoint)controlpoint1 controlpoint2:(cgpoint)controlpoint2;
//畫圓弧
- (void)addarcwithcenter:(cgpoint)center radius:(cgfloat)radius startangle:(cgfloat)startangle endangle:(cgfloat)endangle clockwise:(bool)clockwise
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...