更换热点链接方式

This commit is contained in:
wbzhan
2019-09-30 13:30:50 +08:00
parent 41e5233e1f
commit bfdf208899
10 changed files with 259 additions and 62 deletions
+32 -31
View File
@@ -7,8 +7,8 @@
//
#import "HKPieChartView.h"
#define cycle_blue RGB(174, 191, 228)
#define cycle_green RGB(66, 116, 130)
#define Cycle_DarkBlue RGB(0, 150, 200)
#define Cycle_LightBlue RGB(160, 200, 255)
@interface HKPieChartView()<CAAnimationDelegate>
@property (nonatomic, strong) CAShapeLayer *trackLayer;
@@ -48,10 +48,9 @@
}
- (void)updateUI {
// self.trackColor = RGB(240, 244, 251);
self.trackColor = [UIColor clearColor];
self.progressColor = cycle_green;
self.animationDuration = 100;
self.progressColor = Cycle_DarkBlue;
self.animationDuration = 1;
self.pathWidth = self.frame.size.width - kSizeFrom750(8);
[self shadowImageView];
@@ -59,7 +58,9 @@
[self gradientLayer];
[self loadGesture];
}
- (void)endProgressWithString:(NSString *)text{
self.progressLabel.text = text;
}
- (void)dealloc {
[self invalidateTimer];
}
@@ -117,12 +118,11 @@
CABasicAnimation *animation= [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
animation.fromValue = @(0.0);
animation.toValue = @(self.percent / 100.);
animation.toValue = @(self.percent / 100.f);
animation.duration = self.animationDuration * self.percent / 100;
animation.removedOnCompletion = YES;
animation.delegate = self;
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];
self.progressLayer.strokeEnd = self.percent / 100;
[self.progressLayer addAnimation:animation forKey:@"strokeEndAnimation"];
}
@@ -131,20 +131,20 @@
#pragma mark - CAAnimationDelegate
- (void)animationDidStart:(CAAnimation *)anim {
self.timer = [NSTimer timerWithTimeInterval:1/60 target:self selector:@selector(timerAction) userInfo:nil repeats:YES];
[[NSRunLoop currentRunLoop] addTimer:self.timer forMode:NSRunLoopCommonModes];
self.progressLabel.text = @"设备连接中...";
}
- (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag {
if (flag) {
[self invalidateTimer];
if (self.inCounting&&self.percent==0) {
self.progressLabel.text = @"未开始";
}else
{
self.progressLabel.text = [NSString stringWithFormat:@"%.0f%%", self.percent];
}
}
// if (flag) {
// [self invalidateTimer];
// if (self.inCounting&&self.percent==0) {
// self.progressLabel.text = @"未开始";
// }else
// {
// self.progressLabel.text = [NSString stringWithFormat:@"%.0f%%", self.percent];
// }
// }
}
- (void)timerAction {
@@ -157,7 +157,11 @@
self.progressLabel.text = @"未开始";
}else
{
self.progressLabel.text = [NSString stringWithFormat:@"%0.f%%",floorf(progress * 100)];
NSLog(@"%.2f",progress);
self.progressLabel.text = [NSString stringWithFormat:@"%.0f%%",floorf(progress * 100)];
if (progress>0.5) {
[self updatePercent:100 animation:NO];
}
}
}
@@ -189,12 +193,11 @@
CGFloat radius = (self.frame.size.width- kSizeFrom750(8)*2)/2;
CGFloat startA = -M_PI_2; //设置进度条起点位置
CGFloat endA =-M_PI_2+ M_PI * 2; //设置进度条终点位置
//获取环形路径(画一个圆形,填充色透明,设置线框宽度为10,这样就获得了一个环形)
CAShapeLayer * _backLayer = [CAShapeLayer layer];//创建一个track shape layer
_backLayer.frame = self.bounds;
_backLayer.fillColor = [[UIColor clearColor] CGColor]; //填充色为无色
_backLayer.strokeColor = [cycle_blue CGColor]; //指定path的渲染颜色,这里可以设置任意不透明颜色-淡蓝色
_backLayer.strokeColor = [Cycle_LightBlue CGColor]; //指定path的渲染颜色,这里可以设置任意不透明颜色-淡蓝色
_backLayer.opacity = 1; //背景颜色的透明度
_backLayer.lineCap = kCALineCapRound;//指定线的边缘是圆的
_backLayer.lineWidth = kSizeFrom750(8);//线的宽度
@@ -220,12 +223,10 @@
if (!_gradientLayer) {
_gradientLayer = [CAGradientLayer layer];
_gradientLayer.frame = self.bounds;
_gradientLayer.borderColor = cycle_green.CGColor;
// _gradientLayer.colors = @[(id)[UIColor cyanColor].CGColor,
// (id)[UIColor colorWithRed:0.000 green:0.502 blue:1.000 alpha:1.000].CGColor];
// _gradientLayer.colors = @[(id)HEXCOLOR(@"#4294f8").CGColor,(id)HEXCOLOR(@"#3b82f6").CGColor];
// [_gradientLayer setStartPoint:CGPointMake(0.5, 1.0)];
// [_gradientLayer setEndPoint:CGPointMake(0.5, 0.0)];
// _gradientLayer.colors = @[(id)Cycle_DarkBlue.CGColor,(id)HEXCOLOR(@"#3b82f6").CGColor];
_gradientLayer.colors = @[(id)Cycle_DarkBlue.CGColor,(id)Cycle_DarkBlue.CGColor];
[_gradientLayer setStartPoint:CGPointMake(0.5, 1.0)];
[_gradientLayer setEndPoint:CGPointMake(0.5, 0.0)];
[_gradientLayer setMask:self.progressLayer];
[self.layer addSublayer:_gradientLayer];
@@ -237,10 +238,10 @@
- (UILabel *)progressLabel {
if (!_progressLabel) {
_progressLabel = [[UILabel alloc]initWithFrame:self.bounds];
_progressLabel.textColor = cycle_green;
_progressLabel.textColor = Cycle_DarkBlue;
_progressLabel.textAlignment = NSTextAlignmentCenter;
_progressLabel.font = FontSize(18);
_progressLabel.font = FontSize(14);
_progressLabel.text = @"设备连接中...";
[self addSubview:_progressLabel];
}
return _progressLabel;