贝塞尔曲线
2015-09-01 19:36
381 查看
第一种加载方法
第二种加载方法
- (void)drawRect:(CGRect)rect { UIBezierPath *backPath = [UIBezierPath bezierPath]; [backPath moveToPoint:CGPointMake(0, 0)]; [backPath addLineToPoint:CGPointMake(0, rect.size.height)]; [backPath addLineToPoint:CGPointMake(rect.size.width, rect.size.height)]; [backPath addLineToPoint:CGPointMake(rect.size.width, 0)]; [backPath closePath]; [self.superview.backgroundColor set]; [backPath fill]; CGFloat width = MIN(CGRectGetWidth(rect), CGRectGetHeight(rect)); CGFloat lineW = 3 / [UIScreen mainScreen].scale; UIBezierPath *backProPath = [UIBezierPath bezierPath]; [backProPath addArcWithCenter:CGPointMake(width / 2., width / 2.) radius:width / 2. - 10 startAngle:0 endAngle:M_PI * 2 clockwise:true]; backProPath.lineWidth = lineW; [[UIColor grayColor] set]; [backProPath stroke]; UIBezierPath *progressPath = [UIBezierPath bezierPath]; [progressPath addArcWithCenter:CGPointMake(width / 2., width / 2.) radius:width / 2. - 10 startAngle:0 endAngle:M_PI_4 clockwise:true]; progressPath.lineWidth = lineW; [[UIColor redColor] set]; [progressPath stroke]; }
第二种加载方法
- (void)drawRect:(CGRect)rect { UIBezierPath *tempPath = [UIBezierPath bezierPathWithRect:rect]; [self.superview.backgroundColor set]; [tempPath fill]; CGFloat width = MIN(CGRectGetWidth(rect), CGRectGetHeight(rect)); CAShapeLayer *backLayer = [CAShapeLayer layer]; backLayer.lineWidth = 3 / [UIScreen mainScreen].scale; backLayer.strokeColor = [UIColor cyanColor].CGColor; backLayer.fillColor = [UIColor redColor].CGColor; [self.layer addSublayer:backLayer]; UIBezierPath *backPath = [UIBezierPath bezierPath]; [backPath addArcWithCenter:CGPointMake(width / 2., width / 2.) radius:width / 2. - 3 startAngle:0 endAngle:M_PI_4 clockwise:true]; backLayer.path = backPath.CGPath; }
相关文章推荐
- String对象
- [LintCode] Find the Weak Connected Component in the Directed Graph
- [Leetcode] Different Ways to Add Parentheses
- VIM配置笔记(cscope+NERDTree)
- Safari的常用快捷键
- 我的程序员未婚夫
- 【UVA796】【无向图割边】
- Windows 端口和任务 查看 相关命令
- CRgn::CreateEllipticRgnIn
- 第三方加载图片
- 获取本机外网ip获取位置
- 散列操作的基本例程(1)
- react-native试玩(6)-日期选择控件
- hdu 2002 计算球体积
- oracle 学习sql
- OC03_继承
- leetcode 201:Bitwise AND of Numbers Range
- 计算机为什么要用补码
- Java核心API -- 14(Socket)
- 2015多校联合第二场5308I Wanna Become A 24-Point Master