1.Line cap styles. 線角樣式
typedef CF_ENUM(int32_t, CGLineCap) {
kCGLineCapButt,
kCGLineCapRound,//圓角
kCGLineCapSquare //直角
};
設(shè)置某一個(gè)角可以有圓角(枚舉值)
byRoundingCorners:(UIRectCorner)corners
typedef NS_OPTIONS(NSUInteger, UIRectCorner) {
UIRectCornerTopLeft = 1 << 0,
UIRectCornerTopRight = 1 << 1,
UIRectCornerBottomLeft = 1 << 2,
UIRectCornerBottomRight = 1 << 3,
UIRectCornerAllCorners = ~0UL
};
3.根據(jù)一個(gè)矩形畫曲線(沿著rect 畫)
+ (UIBezierPath*)bezierPathWithRect:(CGRect)rect
4.根據(jù)矩形框的內(nèi)切圓畫曲線
+ (UIBezierPath*)bezierPathWithOvalInRect:(CGRect)rect
5.根據(jù)矩形畫帶圓角的曲線
參數(shù):
cornerRadius 每個(gè)角角度
+ (UIBezierPath*)bezierPathWithRoundedRect:(CGRect)rect cornerRadius:(CGFloat)cornerRadius
內(nèi)切
6.在矩形中可以針對四角中的某個(gè)角加圓角
參數(shù):
corners rect 枚舉值才漆,可以選擇某個(gè)角
cornerRadii 圓角的大小
+ (UIBezierPath*)bezierPathWithRoundedRect:(CGRect)rect byRoundingCorners:(UIRectCorner)corners cornerRadii:(CGSize)cornerRadii
corners 可以 是多個(gè)枚舉值
7.以某個(gè)中心點(diǎn)畫弧線
參數(shù):
center:弧線中心點(diǎn)的坐標(biāo)
radius:弧線所在圓的半徑
startAngle:弧線開始的角度值
endAngle:弧線結(jié)束的角度值
clockwise:是否順時(shí)針畫弧線
+ (UIBezierPath*)bezierPathWithArcCenter:(CGPoint)center radius:(CGFloat)radius startAngle:(CGFloat)startAngle endAngle:(CGFloat)endAngle clockwise:(BOOL)clockwise;
clockwise 為 1
clockwise 為 0
8.畫二元曲線鸳玩,和moveToPoint配合使用
參數(shù):
endPoint:曲線的終點(diǎn)
controlPoint:畫曲線的基準(zhǔn)點(diǎn)
- (void)addQuadCurveToPoint:(CGPoint)endPoint controlPoint:(CGPoint)controlPoint
效果圖
9.以三個(gè)點(diǎn)畫一段曲線颓帝,和moveToPoint配合使用
參數(shù):
endPoint:曲線的終點(diǎn)
controlPoint1:畫曲線的第一個(gè)基準(zhǔn)點(diǎn)
controlPoint2:畫曲線的第二個(gè)基準(zhǔn)點(diǎn)
- (void)addCurveToPoint:(CGPoint)endPoint controlPoint1:(CGPoint)controlPoint1 controlPoint2:(CGPoint)controlPoint2
效果圖
10.閉合路徑
- (void)closePath;
11.移除所有的點(diǎn)
- (void)removeAllPoints;
12.追加路徑
- (void)appendPath:(UIBezierPath *)bezierPath;
追加路徑
13. Modified paths
- (UIBezierPath *)bezierPathByReversingPath NS_AVAILABLE_IOS(6_0);
14.轉(zhuǎn)換路徑
- (void)applyTransform:(CGAffineTransform)transform;
15.路徑信息
@property(readonly,getter=isEmpty) BOOL empty;
@property(nonatomic,readonly) CGRect bounds;
@property(nonatomic,readonly) CGPoint currentPoint;
- (BOOL)containsPoint:(CGPoint)point; //路徑中是否包含這個(gè)點(diǎn)
16. Drawing properties
@property(nonatomic) CGFloat lineWidth; //線寬
@property(nonatomic) CGLineCap lineCapStyle;
@property(nonatomic) CGLineJoin lineJoinStyle; //曲線交叉點(diǎn)的類型
17.兩條線交匯處內(nèi)角和外角之間的最大距離,需要交叉點(diǎn)類型為kCGLineJoinMiter是生效瘪板,最大限制為10 Used when lineJoinStyle is kCGLineJoinMiter
@property(nonatomic) CGFloat miterLimit;
@property(nonatomic) CGFloat flatness;
// 默認(rèn)是NO篷帅。當(dāng)YES時(shí),單雙數(shù)填充規(guī)則用于繪畫,剪裁,點(diǎn)擊測試。
@property(nonatomic) BOOL usesEvenOddFillRule; // Default is NO. When YES, the even-odd fill rule is used for drawing, clipping, and hit testing.
- (void)setLineDash:(nullable const CGFloat *)pattern count:(NSInteger)count phase:(CGFloat)phase;
- (void)getLineDash:(nullable CGFloat *)pattern count:(nullable NSInteger *)count phase:(nullable CGFloat *)phase;
18.對當(dāng)前圖形上下文路徑操作
- (void)fill;
- (void)stroke;
19. 這些方法不影響混合模式或當(dāng)前圖形上下文的α
blendMode 填充顯示樣式 (枚舉值)
alpha 透明度
- (void)fillWithBlendMode:(CGBlendMode)blendMode alpha:(CGFloat)alpha;
blendMode 線的顯示樣式 (枚舉值)
alpha 透明度
- (void)strokeWithBlendMode:(CGBlendMode)blendMode alpha:(CGFloat)alpha;
20.使用當(dāng)前path剪切當(dāng)前的圖形,之后在超出path區(qū)域的地方繪圖將顯示不出來
- (void)addClip;