ios 动画系列之六------UIBezierPath贝塞尔弧线常用方法记

//根据一个矩形画曲线

+ (UIBezierPath *)bezierPathWithRect:(CGRect)rect

 

//根据矩形框的内切圆画曲线

+ (UIBezierPath *)bezierPathWithOvalInRect:(CGRect)rect

 

//根据矩形画带圆角的曲线

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

 

//在矩形中,可以针对四角中的某个角加圆角

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

参数:

corners:枚举值,可以选择某个角

cornerRadii:圆角的大小

 
//以某个中心点画弧线 
+ ( UIBezierPath   *)bezierPathWithArcCenter:( CGPoint )center radius:( CGFloat )radius startAngle:( CGFloat )startAngle endAngle:( CGFloat )endAngle clockwise:( BOOL )clockwise;

参数:

center:弧线中心点的坐标

radius:弧线所在圆的半径

startAngle:弧线开始的角度值

endAngle:弧线结束的角度值

clockwise:是否顺时针画弧线

 

//画二元曲线,一般和moveToPoint配合使用

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

参数:

endPoint:曲线的终点

controlPoint:画曲线的基准点

例子:UIBezierPath *movePath = [UIBezierPath bezierPath];     

      CGPoint fromPoint = self.imageView.center;     

      CGPoint endPoint = CGPointMake(280, 400);    

      [movePath moveToPoint:fromPoint];    //开始点

      [movePath addQuadCurveToPoint:endPoint controlPoint:CGPointMake(280,0)]; //画二元曲线,结束点、控制点

 

 

//以三个点画一段曲线,一般和moveToPoint配合使用

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

参数:

endPoint:曲线的终点

controlPoint1:画曲线的第一个基准点

controlPoint2:画曲线的第二个基准点

 

//自己创建一段曲线

UIBezierPath *path = [UIBezierPath bezierPath];
[path moveToPoint:CGPointMake(0, 100)];//开始点
[path addLineToPoint:CGPointMake(300, 100)];//向这条线上加点

[path addLineToPoint:CGPointMake(300, 200)];
   

转载于:https://www.cnblogs.com/wyqfighting/p/3208078.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值