CustomProgress.m 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. //
  2. // CustomProgress.m
  3. // WisdomPioneer
  4. //
  5. // Created by 主用户 on 16/4/11.
  6. // Copyright © 2016年 江萧. All rights reserved.
  7. //
  8. #import "CustomProgress.h"
  9. @implementation CustomProgress
  10. @synthesize bgimg,leftimg,presentlab;
  11. - (id)initWithFrame:(CGRect)frame {
  12. self = [super initWithFrame:frame];
  13. if (self) {
  14. self.backgroundColor = [UIColor clearColor];
  15. bgimg = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
  16. bgimg.layer.borderColor = [UIColor clearColor].CGColor;
  17. bgimg.layer.borderWidth = 1;
  18. bgimg.layer.cornerRadius = 5;
  19. [bgimg.layer setMasksToBounds:YES];
  20. [self addSubview:bgimg];
  21. leftimg = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 0, self.frame.size.height)];
  22. leftimg.layer.borderColor = [UIColor clearColor].CGColor;
  23. leftimg.layer.borderWidth = 1;
  24. leftimg.layer.cornerRadius = 15;
  25. [leftimg.layer setMasksToBounds:YES];
  26. [self addSubview:leftimg];
  27. presentlab = [[UILabel alloc] initWithFrame:bgimg.bounds];
  28. presentlab.textAlignment = NSTextAlignmentCenter;
  29. presentlab.textColor = [UIColor whiteColor];
  30. presentlab.font = [UIFont systemFontOfSize:16];
  31. [self addSubview:presentlab];
  32. }
  33. return self;
  34. }
  35. -(void)setPresent:(double)present {
  36. presentlab.text = [[NSString alloc] initWithFormat:@"已完成%.2f%%", present];
  37. leftimg.frame = CGRectMake(0, 0, self.frame.size.width/self.maxValue*present, self.frame.size.height);
  38. }
  39. /*
  40. // Only override drawRect: if you perform custom drawing.
  41. // An empty implementation adversely affects performance during animation.
  42. - (void)drawRect:(CGRect)rect {
  43. // Drawing code
  44. }
  45. */
  46. @end