標籤:數值 move tco div turn new nscopying coder mod
#import <Foundation/Foundation.h>#import <CoreGraphics/CoreGraphics.h>#import <UIKit/UIKitDefines.h>NS_ASSUME_NONNULL_BEGINtypedef NS_OPTIONS(NSUInteger, UIRectCorner) { UIRectCornerTopLeft = 1 << 0, UIRectCornerTopRight = 1 << 1, UIRectCornerBottomLeft = 1 << 2, UIRectCornerBottomRight = 1 << 3, UIRectCornerAllCorners = ~0UL};NS_CLASS_AVAILABLE_IOS(3_2) @interface UIBezierPath : NSObject<NSCopying, NSSecureCoding>//初始化+ (instancetype)bezierPath;//初始化一個矩形路徑+ (instancetype)bezierPathWithRect:(CGRect)rect;//初始化一個橢圓路徑,相切矩形的四條邊。+ (instancetype)bezierPathWithOvalInRect:(CGRect)rect;//初始化一個圓角矩形,矩形地區 邊角半徑+ (instancetype)bezierPathWithRoundedRect:(CGRect)rect cornerRadius:(CGFloat)cornerRadius;/** 初始化圓角矩形 @param rect 矩形地區 @param corners 枚舉:哪個角是圓角(多個時用 ‘|’分開) @param cornerRadii 圓角半徑 */+ (instancetype)bezierPathWithRoundedRect:(CGRect)rect byRoundingCorners:(UIRectCorner)corners cornerRadii:(CGSize)cornerRadii;/** 初始化一個開放圓弧路徑 @param center 圓心 @param radius 半徑 @param startAngle 開始角度(0-M_PI) @param endAngle 結束角度 @param clockwise 是否順時針 */+ (instancetype)bezierPathWithArcCenter:(CGPoint)center radius:(CGFloat)radius startAngle:(CGFloat)startAngle endAngle:(CGFloat)endAngle clockwise:(BOOL)clockwise;//根據CGPath初始化對象+ (instancetype)bezierPathWithCGPath:(CGPathRef)CGPath;- (instancetype)init NS_DESIGNATED_INITIALIZER;- (nullable instancetype)initWithCoder:(NSCoder *)aDecoder NS_DESIGNATED_INITIALIZER;//設定路徑,也可以擷取一個不可變的路徑!@property(nonatomic) CGPathRef CGPath;- (CGPathRef)CGPath NS_RETURNS_INNER_POINTER CF_RETURNS_NOT_RETAINED;//移動到當前點- (void)moveToPoint:(CGPoint)point;//到當前點畫一條直線- (void)addLineToPoint:(CGPoint)point;/** 追加畫一條三次貝茲路徑 @param endPoint 結束點 @param controlPoint1 控制點1 @param controlPoint2 控制點2 */- (void)addCurveToPoint:(CGPoint)endPoint controlPoint1:(CGPoint)controlPoint1 controlPoint2:(CGPoint)controlPoint2;/** 追加畫一條二次方貝茲曲線 @param endPoint 結束點 @param controlPoint 控制點 */- (void)addQuadCurveToPoint:(CGPoint)endPoint controlPoint:(CGPoint)controlPoint;/** 追加一條圓弧 @param center 中心點 @param radius 半徑 @param startAngle 開始角度 @param endAngle 結束角度 @param clockwise 是否順時針 */- (void)addArcWithCenter:(CGPoint)center radius:(CGFloat)radius startAngle:(CGFloat)startAngle endAngle:(CGFloat)endAngle clockwise:(BOOL)clockwise NS_AVAILABLE_IOS(4_0);//閉合路徑- (void)closePath;//去除所有路徑- (void)removeAllPoints;//追加bezierPath- (void)appendPath:(UIBezierPath *)bezierPath;// 將原來的UIBezierPath反方向繪製(兩個路徑一樣,方向不一樣)- (UIBezierPath *)bezierPathByReversingPath NS_AVAILABLE_IOS(6_0);// 進行放射,2D變換- (void)applyTransform:(CGAffineTransform)transform;// Path info@property(readonly,getter=isEmpty) BOOL empty; //路徑是否為空白@property(nonatomic,readonly) CGRect bounds; //路徑地區@property(nonatomic,readonly) CGPoint currentPoint; //當前點- (BOOL)containsPoint:(CGPoint)point; //是否包含某個點// Drawing properties@property(nonatomic) CGFloat lineWidth; //線寬@property(nonatomic) CGLineCap lineCapStyle; //曲線終點樣式 枚舉@property(nonatomic) CGLineJoin lineJoinStyle; //曲線串連處樣式 枚舉@property(nonatomic) CGFloat miterLimit; // 串連處lineJoinStyle值是kCGLineJoinMiter,內角與外角距離,最大限制10@property(nonatomic) CGFloat flatness; //渲染精度(預設0.6),數值越小,精度越高也越耗時!@property(nonatomic) BOOL usesEvenOddFillRule; // 是否使用基偶填充規則,(預設是NO 非零規則)/** 繪製虛線路徑 @param pattern C語言數組 CGFloat xx[] = {線段長度,間隙長度}; 輪流 @param count 數組個數 @param phase 從第幾個數開始繪製 */- (void)setLineDash:(nullable const CGFloat *)pattern count:(NSInteger)count phase:(CGFloat)phase;/** 擷取虛線樣式 @param pattern 數組(空間必須大於路徑空間) @param count 數組個數 @param phase 開始位元 */- (void)getLineDash:(nullable CGFloat *)pattern count:(nullable NSInteger *)count phase:(nullable CGFloat *)phase;- (void)fill; //填充- (void)stroke; //畫線/** 混合填充 @param blendMode 填充模式 枚舉 @param alpha 透明度 */- (void)fillWithBlendMode:(CGBlendMode)blendMode alpha:(CGFloat)alpha;/** 混合畫線 @param blendMode 模式 枚舉 @param alpha 透明度 */- (void)strokeWithBlendMode:(CGBlendMode)blendMode alpha:(CGFloat)alpha;//裁剪路徑 之後路徑只能在地區裡畫線- (void)addClip;@endNS_ASSUME_NONNULL_END
iOS之UIBezierPath貝茲路徑屬性簡介