由于前段时间有个项目用SVProgressHUD做提示框和加载框.发现SVProgressHUD作为单例,同时担任提示框和加载框,会有一些小小的交互问题.
个人git demo地址:https://github.com/wyuyung/YungLoadingView
以前刚开始用CGContextRef UIGraphicsGetCurrentContext()进行画图,那么为什么那么多人用bezier曲线[UIBezierPath bezierPath]进行画图?
相同点:画图的静态效果基本是相同的,UIBezierPath能画的图形,CGContextRef都能画.
不同点:UIBezierPath可以和CATransaction联合使用,实现动画效果.例如一个类时钟图像在不断地走时,画一个圈在不断地变化形状旋转.CGContextRef暂时没找到好的组合方法实现动画效果.
简单介绍一下UIBezierPath基本功能:
初始化:
[UIBezierPath bezierPath]
画一根线:
[bezierPath moveToPoint:CGPointMake(inX, inY)];
[bezierPath addLineToPoint:CGPointMake(outX, outY)];
画一个圆:
[bezierPath addArcWithCenter:CGPointMake(CGRectGetWidth(self.frame) / 2, CGRectGetHeight(self.frame) / 2) radius:1 startAngle:0 endAngle:M_PI * 2 clockwise:YES];
或者直接初始化一个半圆也可以
[UIBezierPath bezierPathWithArcCenter:CGPointMake(CGRectGetWidth(self.frame) / 2, CGRectGetHeight(self.frame) / 2)
radius:(CGRectGetWidth(self.frame) - lineWidth - 2) / 2
startAngle:M_PI / 12.
endAngle:M_PI * 14 / 12.
clockwise:YES]