// 画矩形
- (void)drawJX {
UIBezierPath *path = [UIBezierPath bezierPathWithRect: CGRectMake(110, 100, 150, 100)];
CAShapeLayer *layer = [CAShapeLayer layer];
layer.path = path.CGPath;
layer.fillColor = [UIColor blackColor].CGColor; // storke空心, fill实心
[self.view.layer addSublayer: layer];
}
// 圆角图形
- (void)drawYJ {
UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(110, 100, 150, 100) cornerRadius:50];
CAShapeLayer *layer = [CAShapeLayer layer];
layer.path = path.CGPath;
layer.fillColor = [UIColor clearColor].CGColor; // 填充色
layer.strokeColor = [UIColor blackColor].CGColor; // 边框颜色
[self.view.layer addSublayer: layer];
}
// 画圆
- (void)drawYuan {
CGFloat radius = 60.0f;
CGFloat startAngle = 0.0f;
CGFloat endAngle = M_PI * 2;
UIBezierPath *path = [UIBezierPath bezierPathWithArcCenter:self.view.center radius:radius star
OC笔记-贝塞尔曲线的应用
最新推荐文章于 2021-09-02 12:29:30 发布
这篇博客介绍了如何使用UIBezierPath在iOS中绘制不同形状,包括矩形、圆角矩形、圆、曲线和多控制点曲线。通过示例代码展示了如何创建CAShapeLayer并应用贝塞尔曲线路径,实现动态效果,如平滑的动画过渡。
摘要由CSDN通过智能技术生成