PercentView 一个圆形百分比View 现在很多的App都有这么一个小小的View

网友投稿 521 2022-11-05

PercentView 一个圆形百分比View 现在很多的App都有这么一个小小的View

PercentView 一个圆形百分比View 现在很多的App都有这么一个小小的View

PercentView

一个圆形百分比View 现在很多的App都有这么一个小小的View。 可以用在显示你剩余流量占总流量的百分比,也可以显示你当前进度占总进度的百分比。 #参数,属性

//目标layer@property (nonatomic, strong) CAShapeLayer *progressLayer;//渐变夜色@property (nonatomic, strong) CAGradientLayer *gradientLayer;//整个圆的颜色@property (nonatomic, strong) UIColor *trackColor;//目标长度的颜色,但是设置gradientLayer的颜色之后就失效了@property (nonatomic, strong) UIColor *progressColor;//线宽@property (nonatomic, assign) CGFloat lineWidth;//贝塞尔曲线@property (nonatomic, strong) UIBezierPath *path;//百分比,最大值为100@property (nonatomic, assign) CGFloat percent;//动画时间@property (nonatomic, assign) CGFloat duration;//定时器@property (nonatomic, strong) NSTimer *timer;//阴影@property (nonatomic, strong) UIImageView *shadowImageView;//宽度@property (nonatomic, assign) CGFloat pathWidth;//目标百分比显示@property (nonatomic, strong) UILabel *progressLabel;

其中gradientLayer可以设置多个颜色,做成那种颜色渐变的效果

_gradientLayer.colors = @[(id)[UIColor redColor].CGColor, (id)[UIColor yellowColor].CGColor ]; [_gradientLayer setStartPoint:CGPointMake(0.5, 1.0)]; [_gradientLayer setEndPoint:CGPointMake(0.5, 0.0)];

#使用方法 就是一般的初始化就可以了

- (ZPPercentView *)percentView{ if (!_percentView) { CGFloat width = 150; _percentView = [[ZPPercentView alloc]initWithFrame:CGRectMake((self.view.frame.size.width - width)/2, 150, width, width)]; [_percentView updateZPPercent:@(80.0).floatValue openAnimation:YES]; [self.view addSubview:_percentView]; } return _percentView;}

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:一篇文章带你了解Maven的继承和聚合
下一篇:NodeJS中的递归多线程工作进程
相关文章

 发表评论

暂时没有评论,来抢沙发吧~