快速上手IOS UIBezierPath(贝塞尔曲线)

2020-01-18 21:43:05王旭

uibezierpath,ios,贝塞尔曲线,贝塞尔曲线案例

设置颜色


UIBezierPath *path = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(100, 100, 100, 100)];
[[UIColor greenColor] setStroke];
[[UIColor redColor] setFill];
[path stroke];
[path fill];

uibezierpath,ios,贝塞尔曲线,贝塞尔曲线案例

设置描边混合模式


UIBezierPath *path = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(100, 100, 100, 100)];
[[UIColor greenColor] setStroke];
path.lineWidth = 10.0f;
[path strokeWithBlendMode:kCGBlendModeSaturation alpha:1.0];
[path stroke];
 

uibezierpath,ios,贝塞尔曲线,贝塞尔曲线案例


UIBezierPath *path = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(100, 100, 100, 100)];
 [[UIColor redColor] setFill];
 [path fillWithBlendMode:kCGBlendModeSaturation alpha:0.6];
 [path fill];

uibezierpath,ios,贝塞尔曲线,贝塞尔曲线案例

修改当前图形上下文的绘图区域可见,随后的绘图操作导致呈现内容只有发生在指定路径的填充区域


UIBezierPath *path = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(100, 100, 100, 100)];
[[UIColor greenColor] setStroke];
[path addClip];
[path stroke];

uibezierpath,ios,贝塞尔曲线,贝塞尔曲线案例

结语

关于UIBezierPath的简单介绍就到这了,主要是用代码做了展示,属性跟方法,没详细去介绍,我觉得可以直接看苹果的api写的也蛮清楚的.或者自己试试不同的参数样式也能大概理解了.

核心动画跟贝赛尔曲线都有了简单的介绍了,接下来就可以动手做点简单的自定义动画了.

以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,同时也希望多多支持ASPKU!


注:相关教程知识阅读请移步到IOS开发频道。