-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathLYCCircleAnimationView.m
More file actions
executable file
·143 lines (121 loc) · 4.42 KB
/
LYCCircleAnimationView.m
File metadata and controls
executable file
·143 lines (121 loc) · 4.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
//
// LYCCircleAnimationView.m
// LYCCarProgressAnimation
//
// Created by mac on 2017/6/21.
// Copyright © 2017年 com.liuyanchi.www. All rights reserved.
//
#import "LYCCircleAnimationView.h"
#import "LYCCircleView.h"
#import "LYCPointerView.h"
#import "Masonry.h"
#define RGBA(r,g,b,a) [UIColor colorWithRed:(float)r/255.0f green:(float)g/255.0f blue:(float)b/255.0f alpha:a]
#define AnimationIntertime 1.5
@interface LYCCircleAnimationView ()<UIGestureRecognizerDelegate>
@property (nonatomic, strong) LYCCircleView *circleView;
@property (nonatomic, strong) LYCPointerView *pointerView;
@property(strong,nonatomic)UILabel *targetLab;
@property (strong, nonatomic) UILabel *finishLab;
@property (strong, nonatomic) UILabel *practiceLab;
@property (strong, nonatomic) UIImageView *imgView;
@end
@implementation LYCCircleAnimationView
-(instancetype)initWithFrame:(CGRect)frame{
self = [super initWithFrame:frame];
if (self) {
[self configViews];
}
return self;
}
-(void)configViews{
[self addSubview:self.finishLab];
[self addSubview:self.practiceLab];
[self addSubview:self.targetLab];
[self addSubview:self.imgView];
[self instanceCircle];
[self instancePointerView];
[self.imgView mas_makeConstraints:^(MASConstraintMaker *make) {
make.center.equalTo(self);
}];
[self.practiceLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.center.equalTo(self);
}];
[self.finishLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self.practiceLab);
make.bottom.equalTo(self.practiceLab.mas_top).offset(-7);
}];
[self.targetLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self.practiceLab);
make.top.equalTo(self.practiceLab.mas_bottom).offset(7);
}];
//图像添加点击事件(手势方法)
UITapGestureRecognizer * PrivateLetterTap=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapAvatarView:)];
PrivateLetterTap.numberOfTouchesRequired = 1; //手指数
PrivateLetterTap.numberOfTapsRequired = 1; //tap次数
PrivateLetterTap.delegate= self;
self.imgView.contentMode = UIViewContentModeScaleToFill;
[self.imgView addGestureRecognizer:PrivateLetterTap];
}
- (void)tapAvatarView: (UITapGestureRecognizer *)gesture
{
}
//初始化圆圈
-(void)instanceCircle{
self.circleView = [[LYCCircleView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.frame), CGRectGetHeight(self.frame))];
[self addSubview:self.circleView];
}
-(void)instancePointerView{
self.pointerView = [[LYCPointerView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.frame), CGRectGetHeight(self.frame))];
[self addSubview:self.pointerView];
}
//set
-(void)setPercentStr:(NSString *)percentStr{
self.practiceLab.text = [NSString stringWithFormat:@"%.2f",[percentStr floatValue]];
if(![_percentStr isEqualToString:percentStr]){
[self.pointerView updatePointer:[percentStr integerValue] withAnimationTime:[percentStr integerValue]/100 *AnimationIntertime];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.96 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self.circleView makeCircle:[percentStr integerValue] withAnimationTime:AnimationIntertime];
});
}
_percentStr = percentStr;
}
- (UILabel *)finishLab
{
if (!_finishLab) {
_finishLab = [[UILabel alloc] init];
_finishLab.text = @"已完成";
_finishLab.textColor = [UIColor whiteColor];
_finishLab.font = [UIFont systemFontOfSize:14.f];
}
return _finishLab;
}
- (UILabel *)targetLab
{
if (!_targetLab) {
_targetLab = [[UILabel alloc] init];
_targetLab.text = @"目标:100小时";
_targetLab.textColor = [UIColor whiteColor];
_targetLab.font = [UIFont systemFontOfSize:12.f];
}
return _targetLab;
};
- (UILabel *)practiceLab
{
if (!_practiceLab) {
_practiceLab = [[UILabel alloc] init];
_practiceLab.text = @"0.00";
_practiceLab.textColor = [UIColor whiteColor];
_practiceLab.font = [UIFont boldSystemFontOfSize:29.f];
}
return _practiceLab;
}
- (UIImageView *)imgView
{
if (!_imgView) {
_imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ppc_track"]];
[_imgView sizeToFit];
_imgView.userInteractionEnabled = YES;
}
return _imgView;
}
@end