123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- //
- // YQGradientProgressView.m
- // shehui
- //
- // Created by pajia on 16/7/6.
- // Copyright © 2016年 happyfirst. All rights reserved.
- //
- #import "YQGradientProgressView.h"
- #import "UIView+AZGradient.h"
- @implementation YQGradientProgressModel
- @end
- @interface YQGradientProgressView()
- {
- UIView *_pView;
- // CAGradientLayer *_gradientLayer;
- }
- @end
- @implementation YQGradientProgressView
- - (id)init{
- if (self = [super init]) {
- [self setupView];
- }
- return self;
- }
- - (void)setupView{
- self.backgroundColor = [UIColor clearColor];
- kViewRadius(self, 2);
-
- _pView = [[UIView alloc] init];
- kViewRadius(_pView, 2);
- [self addSubview:_pView];
-
- // _gradientLayer = [CAGradientLayer layer];
- // [_pView.layer addSublayer:_gradientLayer];
- }
- - (void)setProgress:(float)progress{
- _progress = progress;
- if (_progress > 1.0) {
- _progress = 1.0;
- }
- if (_progress < 0) {
- _progress = 0;
- }
- float width = progress*self.frame.size.width;
-
- _pView.frame = CGRectMake(0, 0, width, 4);
- // _gradientLayer.frame = _pView.frame;
-
- [self reloadColor];
-
- }
- - (void)reloadColor{
-
- self.backgroundColor = [UIColor colorWithHexString:self.colorMoodel.backGroundColor alpha:0.1];
-
- // UIColor *color1,*color2;
- //if (_progress <= 0.5) {
- // color1 = [UIColor colorWithHexString:@"4ad7ff" alpha:1];
- //color2 = [UIColor colorWithHexString:@"1bc1ff" alpha:1];
- //}else{
- // color1 = [UIColor colorWithHexString:@"ffd33a" alpha:1];
- // color2 = [UIColor colorWithHexString:@"ffa126" alpha:1];
- //}
- //set gradient colors
-
- // color1 = [UIColor colorWithHexString:self.colorMoodel.startColor alpha:1];
- // color2 = [UIColor colorWithHexString:self.colorMoodel.endColor alpha:1];
- // _gradientLayer.colors = @[(__bridge id)color1.CGColor, (__bridge id)color2.CGColor];
- // //set gradient start and end points
- // _gradientLayer.startPoint = CGPointMake(0, 0.5);
- // _gradientLayer.endPoint = CGPointMake(1, 0.5);
-
- [_pView az_setGradientBackgroundWithColors:@[[UIColor colorWithHexString:self.colorMoodel.startColor alpha:1],[UIColor colorWithHexString:self.colorMoodel.endColor alpha:1]] locations:nil startPoint:CGPointMake(0, 0.5) endPoint:CGPointMake(1, 0.5)];
- }
- /*
- // Only override drawRect: if you perform custom drawing.
- // An empty implementation adversely affects performance during animation.
- - (void)drawRect:(CGRect)rect {
- // Drawing code
- }
- */
- @end
|