CAShapeLayer的属性 path, 配合上 UIBezierPath(贝塞尔曲线)使用
来源:互联网 发布:淘宝店铺全屏轮播海报 编辑:程序博客网 时间:2024/06/05 14:49
//// ViewController.m//#import "ViewController.h"@interface ViewController ()@end@implementation ViewController- (void)viewDidLoad { [super viewDidLoad]; /* 1.CAShapeLayer的属性 path, 配合上 UIBezierPath(贝塞尔曲线)使用。 2.fillColor 和 strokeColor ,前者代表设置这个 Layer 的填充色,后者代表设置它的边框色 3.贝塞尔曲线的画法是由起点、终点、控制点三个参数来画的 4.控制点决定了它的曲率,曲线的顶点不等于控制点的位置,具体可以看一下贝塞尔曲线的定义 */}// 一:带边框的view- (IBAction)TestOne:(id)sender { UIBezierPath * path = [UIBezierPath bezierPathWithRect:CGRectMake(100, 100, 100, 100)]; CAShapeLayer * layer = [CAShapeLayer layer]; layer.fillColor = [[UIColor grayColor] CGColor]; layer.strokeColor =[[UIColor greenColor] CGColor]; layer.path = path.CGPath; [self.view.layer addSublayer:layer];}// 二:圆框- (IBAction)TestTwo:(id)sender { UIBezierPath * path = [UIBezierPath bezierPathWithArcCenter:CGPointMake(self.view.center.x, self.view.center.y) radius:50 startAngle:0 endAngle:2*M_PI clockwise:true]; CAShapeLayer * layer = [CAShapeLayer layer]; layer.fillColor = [[UIColor clearColor] CGColor]; layer.strokeColor =[[UIColor greenColor] CGColor]; layer.path = path.CGPath; [self.view.layer addSublayer:layer];}// 三:曲线- (IBAction)TestThree:(id)sender { CGPoint startPoint = CGPointMake(50, 500); CGPoint endPoint = CGPointMake(250, 500); CGPoint controlPoint = CGPointMake(150, 400); UIBezierPath * path = [UIBezierPath bezierPath]; [path moveToPoint:startPoint]; [path addQuadCurveToPoint:endPoint controlPoint:controlPoint]; CAShapeLayer * layer = [CAShapeLayer layer]; layer.path = path.CGPath; layer.fillColor = [[UIColor clearColor] CGColor]; layer.strokeColor =[[UIColor greenColor] CGColor]; [self.view.layer addSublayer:layer];}@end
效果图
阅读全文
0 0
- CAShapeLayer的属性 path, 配合上 UIBezierPath(贝塞尔曲线)使用
- 使用CAShapeLayer的path属性与UIBezierPath画出扫描框
- UIBezierPath + CAShapeLayer的简单使用
- CAShapeLayer和UIBezierPath的使用
- 贝塞尔曲线收录:四,使用UIBezierPath和CAShapeLayer画各种图形
- iOS 简单的贝塞尔(UIBezierPath)曲线使用
- CAShapeLayer与UIBezierPath的结合使用
- 使用CAShapeLayer与UIBezierPath
- iOS 贝塞尔曲线和CAShapeLayer 结合使用的进度条详解
- iOS 雷达图的绘制 贝塞尔曲线的使用UIBezierPath
- 仿QQ头像透明圆图剪切(CAShapeLayer 和 UIBezierPath的使用)
- 使用CAShapeLayer与UIBezierPath画出想要的图形
- 使用CAShapeLayer与UIBezierPath画出想要的图形
- 使用CAShapeLayer与UIBezierPath画出想要的图形
- 使用CAShapeLayer与UIBezierPath画出想要的图形
- 使用CAShapeLayer与UIBezierPath画出想要的图形 -- 下载进度条
- 使用CAShapeLayer与UIBezierPath画出想要的圆弧形进度条
- 使用CAShapeLayer与UIBezierPath画出想要的图形
- HDU 5726 GCD (rmq+二分 or 线段树 维护区间gcd)
- Java设计模式编程中的状态模式和策略模式
- 大热的机器学习,身为程序员的你该如何开启?
- Ambari——大数据平台的搭建利器(Ambari 的架构和工作原理)
- 第3周项目1(1)- 顺序表的基本运算
- CAShapeLayer的属性 path, 配合上 UIBezierPath(贝塞尔曲线)使用
- OPENGL常用坐标系介绍
- yum源的超级简单配置
- 渐变测试
- websocket(聊天功能)
- NYOJ 39
- Sky number
- Security-OAuth2.0 密码模式客户端实现(IDEA+springboot+maven)
- 关键字 assert