| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- //
- // CSFileDownLoadControllerView.m
- // zhuxun
- //
- // Created by winsoft on 17/6/22.
- //
- //
- #import "CSFileDownLoadControllerView.h"
- #import "DACircularProgressView.h"
- @interface CSFileDownLoadControllerView()
- @property (nonatomic , weak) UIButton *controllerBtn;
- @property (nonatomic , weak) DACircularProgressView *processView;
- @end
- @implementation CSFileDownLoadControllerView
- - (instancetype)init
- {
- if (self = [super init]) {
-
-
- DACircularProgressView *processView = [[DACircularProgressView alloc] initWithFrame:CGRectMake(0, 0, self.circleSizeWH, self.circleSizeWH)];;
- processView.trackTintColor = [UIColor lightGrayColor];
- processView.progressTintColor = [UIColor blueColor];
- processView.innerTintColor = [UIColor whiteColor];
-
- processView.thicknessRatio = 0.1;
- [self addSubview:processView];
- self.processView = processView;
-
-
- UIButton *controllerBtn = [[UIButton alloc]init];
- [controllerBtn addTarget:self action:@selector(downUpContro) forControlEvents:UIControlEventTouchUpInside];
- UIImage *fav_circle_procss_image = [UIImage imageNamed:@"fav_pause_normal"];
- _circleSizeWH = fav_circle_procss_image.size.width;
-
- [controllerBtn setImage:fav_circle_procss_image forState:UIControlStateNormal];
- [controllerBtn setImage:[UIImage imageNamed:@"fav_pause_pressed"] forState:UIControlStateSelected];
-
- [self addSubview:controllerBtn];
-
- self.controllerBtn = controllerBtn;
- }
-
- return self;
- }
- - (void)downUpContro
- {
- if (self.downUpStatus == DownUpStatusDoing || self.downUpStatus == DownUpStatusWait) {
- self.downUpStatus = DownUpStatusPause;
- }else if (self.downUpStatus == DownUpStatusFailure || self.downUpStatus == DownUpStatusPause)
- {
- self.downUpStatus = DownUpStatusWait;
- }
-
- if (self.downUpStatusChangeBlock) {
- self.downUpStatusChangeBlock(self.downUpStatus);
- }
- }
- - (void)setDownUpStatus:(DownUpStatus)downUpStatus
- {
- _downUpStatus = downUpStatus;
-
- /* DownUpStatusWait = 0,//默认为排队等待.
- DownUpStatusDoing,
- DownUpStatusPause,//Pause->恢复doing时判断是否有其他进行,是则=wait.
- DownUpStatusSuccess,
- DownUpStatusFailure*/
-
- if (downUpStatus == DownUpStatusWait || downUpStatus == DownUpStatusDoing ) {
- [self.controllerBtn setImage:[UIImage imageNamed:@"fav_pause_normal"] forState:UIControlStateNormal];
- [self.controllerBtn setImage:[UIImage imageNamed:@"fav_pause_pressed"] forState:UIControlStateSelected];
- }else if (downUpStatus == DownUpStatusPause || downUpStatus == DownUpStatusFailure) {
- [self.controllerBtn setImage:[UIImage imageNamed:@"fav_download_normal"] forState:UIControlStateNormal];
- [self.controllerBtn setImage:[UIImage imageNamed:@"fav_download_pressed"] forState:UIControlStateSelected];
- }
- }
- - (void)setPercent:(CGFloat)percent
- {
- // self.processView.progress = percent;
-
- [self.processView setProgress:percent animated:NO initialDelay:0];
- }
- - (void)layoutSubviews
- {
- [super layoutSubviews];
-
- self.processView.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);
-
- CGFloat btnWH = self.frame.size.width * 0.9;
-
- self.controllerBtn.frame = CGRectMake((self.frame.size.width - btnWH)/2.0f, (self.frame.size.height - btnWH)/2.0f, btnWH, btnWH);
-
- }
- @end
|