#import <UIKit/UIKit.h>

@interface TJCircleProgressView : UIView
/**
* 图标
*/
@property(nonatomic,strong)UIImage *imgIcon;
/**
* 进度条值
*/
@property(nonatomic,assign)CGFloat progressValue;
/**
* 进度条宽度
*/
@property(nonatomic,assign)CGFloat progressWidth; /**
* 进度条颜色
*/
@property(nonatomic,strong)UIColor *progressColor; @end
#import "TJCircleProgressView.h"
@interface TJCircleProgressView ()
{
UIBezierPath *circlePath;//布赛尔曲线
CAShapeLayer *shapeLayer;// 圆形图层
CAShapeLayer *imgLayer;//图标图层 }
@end
@implementation TJCircleProgressView
@synthesize progressColor = _progressColor;
@synthesize imgIcon = _imgIcon;
@synthesize progressValue = _progressValue;
@synthesize progressWidth = _progressWidth; - (instancetype)initWithFrame:(CGRect)frame
{
if (self = [super initWithFrame:frame])
{
self.backgroundColor = [UIColor whiteColor];
circlePath = [UIBezierPath bezierPathWithOvalInRect:self.bounds]; shapeLayer = [CAShapeLayer layer];
shapeLayer.frame = self.bounds;
shapeLayer.strokeColor = [UIColor redColor].CGColor;
shapeLayer.fillColor = [UIColor clearColor].CGColor;
shapeLayer.path = circlePath.CGPath; shapeLayer.lineWidth = 1.0f;
[self.layer addSublayer:shapeLayer];
}
return self;
}
- (void)setImgIcon:(UIImage *)imgIcon
{
_imgIcon = imgIcon;
imgLayer = [CAShapeLayer layer];
imgLayer.frame = CGRectMake(, , imgIcon.size.width, imgIcon.size.height);
imgLayer.contents = (__bridge id)imgIcon.CGImage;
imgLayer.position = shapeLayer.position;
[self.layer addSublayer:imgLayer]; }
- (void)setProgressValue:(CGFloat)progressValue
{
_progressValue = progressValue;
shapeLayer.strokeEnd = progressValue;
[self startAnimation];
/**延时4秒后移除动画以及view*/
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)( * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self stopAnimation];
});
}
- (void)setProgressWidth:(CGFloat)progressWidth
{
_progressWidth = progressWidth;
shapeLayer.lineWidth = progressWidth;
}
- (void)setProgressColor:(UIColor *)progressColor
{
_progressColor = progressColor;
shapeLayer.strokeColor = progressColor.CGColor;
}
-(void)startAnimation
{
[shapeLayer removeAnimationForKey:@"RotationAnimation"]; CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
animation.fromValue = @();
animation.toValue = @(M_PI * );
animation.repeatCount = MAXFLOAT;
animation.duration = 0.5f;
animation.fillMode = kCAFillModeForwards; [shapeLayer addAnimation:animation forKey:@"RotationAnimation"];
}
- (void)stopAnimation
{
[shapeLayer removeAllAnimations];
[self removeFromSuperview];
}
@end
#import "ViewController.h"
#import "TJCircleProgressView.h"
@interface ViewController ()
{
TJCircleProgressView *circleProgressView;
}
@end @implementation ViewController - (void)viewDidLoad {
[super viewDidLoad];
circleProgressView = [[TJCircleProgressView alloc]initWithFrame:CGRectMake(,, , )];
circleProgressView.center = self.view.center;
[circleProgressView setProgressValue:0.75];
[circleProgressView setProgressColor:[UIColor grayColor]];
[circleProgressView setProgressWidth:1.0f];
[circleProgressView setImgIcon:[UIImage imageNamed:@"refresh"]];
[self.view addSubview:circleProgressView]; } - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
} @end

ps:licecap录取动画没录好

最新文章

  1. RBAC权限管理
  2. swift 命名,字符串
  3. CSS实现完美垂直居中
  4. WebForm带有图片的验证码
  5. Yii2的view需要链接跳转
  6. Python中的高阶函数与匿名函数
  7. centreon load average 的含义
  8. node.js Web应用框架Express.js(一)
  9. java总结文章
  10. 【JUnit4.10来源分析】0导航
  11. 傲梅分区助手专业版 v6.2 中文免费版
  12. 三十分钟学会AWK
  13. 百度播放器SDK 播放MP4格式视频有声音无画面问题解决
  14. c#多线程thread实例详解
  15. DiscuzX2.5,X3.0,X3.1,X3.2完整目录结构【模板目录template】
  16. 10分钟学会使用YOLO及Opencv实现目标检测(下)|附源码
  17. 移动端网页 rem css书写
  18. Spring Jdbc 框架整合的第一天
  19. React项目中实现右键自定义菜单
  20. Hibernate Tools生成注释

热门文章

  1. Java模板引擎 FreeMarker
  2. 串口发送浮点型数据及int(2个字节)long int(4个字节)的方法
  3. 完成端口iocp——在螺丝壳里做道场
  4. sql2008来远程访问sql2005数据库服务器
  5. Visual Studio 2012 主题下的代码配色方案
  6. yum update Transaction Check Error
  7. Putty 工具 保存配置的 小技巧
  8. ISA中的WEB链
  9. ProcessBuilder和Runtime远程执行
  10. 反射遍历List&lt;&gt;泛型类型