美文网首页
UIBezierPath贝塞尔曲线

UIBezierPath贝塞尔曲线

作者: linzaifei | 来源:发表于2017-06-07 22:44 被阅读17次
    1.Line cap styles. 线角样式
    typedef CF_ENUM(int32_t, CGLineCap) {
      kCGLineCapButt,
      kCGLineCapRound,//圆角
      kCGLineCapSquare //直角
    };
    
    设置某一个角可以有圆角(枚举值)

    byRoundingCorners:(UIRectCorner)corners

    typedef NS_OPTIONS(NSUInteger, UIRectCorner) {
      UIRectCornerTopLeft    = 1 << 0,
      UIRectCornerTopRight    = 1 << 1,
      UIRectCornerBottomLeft  = 1 << 2,
      UIRectCornerBottomRight = 1 << 3,
      UIRectCornerAllCorners  = ~0UL
    };
    
    3.根据一个矩形画曲线(沿着rect 画)
    + (UIBezierPath*)bezierPathWithRect:(CGRect)rect
    
    4.根据矩形框的内切圆画曲线
    + (UIBezierPath*)bezierPathWithOvalInRect:(CGRect)rect
    
    5.根据矩形画带圆角的曲线
    参数:
    cornerRadius 每个角角度    
    
    + (UIBezierPath*)bezierPathWithRoundedRect:(CGRect)rect cornerRadius:(CGFloat)cornerRadius
    
    内切
    6.在矩形中可以针对四角中的某个角加圆角
    参数:
    corners rect 枚举值,可以选择某个角
    cornerRadii  圆角的大小
    
    + (UIBezierPath*)bezierPathWithRoundedRect:(CGRect)rect byRoundingCorners:(UIRectCorner)corners cornerRadii:(CGSize)cornerRadii
    
    corners 可以 是多个枚举值
    7.以某个中心点画弧线
    参数:
    center:弧线中心点的坐标
    radius:弧线所在圆的半径
    startAngle:弧线开始的角度值
    endAngle:弧线结束的角度值
    clockwise:是否顺时针画弧线
    
    + (UIBezierPath*)bezierPathWithArcCenter:(CGPoint)center radius:(CGFloat)radius startAngle:(CGFloat)startAngle endAngle:(CGFloat)endAngle clockwise:(BOOL)clockwise;
    
    clockwise 为 1 clockwise 为 0
    8.画二元曲线,和moveToPoint配合使用
    参数:
    endPoint:曲线的终点
    controlPoint:画曲线的基准点
    
    - (void)addQuadCurveToPoint:(CGPoint)endPoint controlPoint:(CGPoint)controlPoint
    
    效果图
    9.以三个点画一段曲线,和moveToPoint配合使用
    参数:
    endPoint:曲线的终点
    controlPoint1:画曲线的第一个基准点
    controlPoint2:画曲线的第二个基准点
    
    - (void)addCurveToPoint:(CGPoint)endPoint controlPoint1:(CGPoint)controlPoint1 controlPoint2:(CGPoint)controlPoint2
    
    效果图
    10.闭合路径
    - (void)closePath;
    
    11.移除所有的点
    - (void)removeAllPoints;
    
    12.追加路径
    - (void)appendPath:(UIBezierPath *)bezierPath;
    

    追加路径

    13. Modified paths
    - (UIBezierPath *)bezierPathByReversingPath NS_AVAILABLE_IOS(6_0);
    
    14.转换路径
    - (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; //路径中是否包含这个点
    
    16. Drawing properties
    @property(nonatomic) CGFloat lineWidth; //线宽
    @property(nonatomic) CGLineCap lineCapStyle;
    @property(nonatomic) CGLineJoin lineJoinStyle; //曲线交叉点的类型
    
    17.两条线交汇处内角和外角之间的最大距离,需要交叉点类型为kCGLineJoinMiter是生效,最大限制为10 Used when lineJoinStyle is kCGLineJoinMiter
    @property(nonatomic) CGFloat miterLimit;
    @property(nonatomic) CGFloat flatness;
    // 默认是NO。当YES时,单双数填充规则用于绘画,剪裁,点击测试。
     @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.对当前图形上下文路径操作
    - (void)fill;
    - (void)stroke;
    
    19. 这些方法不影响混合模式或当前图形上下文的α
    blendMode 填充显示样式 (枚举值)
    alpha 透明度
    - (void)fillWithBlendMode:(CGBlendMode)blendMode alpha:(CGFloat)alpha;
    
    blendMode 线的显示样式 (枚举值)
    alpha 透明度
    - (void)strokeWithBlendMode:(CGBlendMode)blendMode alpha:(CGFloat)alpha;
    
    20.使用当前path剪切当前的图形,之后在超出path区域的地方绘图将显示不出来
    - (void)addClip;

    相关文章

      网友评论

          本文标题:UIBezierPath贝塞尔曲线

          本文链接:https://www.haomeiwen.com/subject/ddoafxtx.html