MyTeamHeader.m 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. //
  2. // MyTeamHeader.m
  3. // model
  4. //
  5. // Created by Drew on 2018/10/29.
  6. // Copyright © 2018 Mine. All rights reserved.
  7. //
  8. #import "MyTeamHeader.h"
  9. @interface MyTeamHeader()
  10. @property (weak, nonatomic) IBOutlet UIView *content;
  11. @property (weak, nonatomic) IBOutlet UILabel *inviteLabel;
  12. @property (weak, nonatomic) IBOutlet UILabel *rewardLabel;
  13. @property (weak, nonatomic) IBOutlet UILabel *labelAuth;
  14. @property (weak, nonatomic) IBOutlet UILabel *labelAuthed;
  15. @property (weak, nonatomic) IBOutlet UIView *coinView;
  16. @end
  17. @implementation MyTeamHeader
  18. - (instancetype)initWithFrame:(CGRect)frame {
  19. if (self = [super initWithFrame:frame]) {
  20. [self initView];
  21. }
  22. return self;
  23. }
  24. - (instancetype)initWithCoder:(NSCoder *)aDecoder {
  25. if (self = [super initWithCoder:aDecoder]) {
  26. [self initView];
  27. }
  28. return self;
  29. }
  30. - (void) initView {
  31. NSBundle *bundle = [NSBundle bundleForClass:[self class]];
  32. NSString *className = NSStringFromClass([self class]);
  33. UIView *view = [[bundle loadNibNamed:className owner:self options:nil] firstObject];
  34. view.frame = self.bounds;
  35. [self addSubview:view];
  36. self.content.clipsToBounds = YES;
  37. }
  38. - (void)layoutSubviews {
  39. [super layoutSubviews];
  40. // gradient
  41. CAGradientLayer *gl = [CAGradientLayer layer];
  42. gl.frame = CGRectMake(0, 0, ScreenWidth - 40, self.bounds.size.height - 22);
  43. gl.startPoint = CGPointMake(0.03, 0.47);
  44. gl.endPoint = CGPointMake(0.97, 0.47);
  45. gl.colors = @[(__bridge id)[UIColor colorWithRed:251/255.0 green:92/255.0 blue:163/255.0 alpha:1].CGColor, (__bridge id)[UIColor colorWithRed:253/255.0 green:127/255.0 blue:141/255.0 alpha:1].CGColor];
  46. gl.locations = @[@(0), @(1.0f)];
  47. self.content.layer.cornerRadius = 12;
  48. [self.content.layer insertSublayer:gl atIndex:0];
  49. }
  50. - (void)setType:(NSString *)type {
  51. _type = type;
  52. if ([@"model" isEqualToString:type]) {
  53. self.coinView.hidden = YES;
  54. self.labelAuth.hidden = NO;
  55. self.labelAuthed.hidden = YES;
  56. } else {
  57. self.coinView.hidden = NO;
  58. self.labelAuth.hidden = YES;
  59. self.labelAuthed.hidden = YES;
  60. }
  61. }
  62. - (void)setIntroduceNum:(NSString*)introduceNum {
  63. _introduceNum = introduceNum;
  64. self.inviteLabel.text = introduceNum;
  65. if ([@"model" isEqualToString:self.type] && [introduceNum intValue] >= 9) {
  66. self.coinView.hidden = NO;
  67. self.labelAuth.hidden = YES;
  68. self.labelAuthed.hidden = NO;
  69. }
  70. }
  71. - (void)setTotalCoin:(NSString*)totalCoin {
  72. _totalCoin = totalCoin;
  73. self.rewardLabel.text = totalCoin;
  74. }
  75. @end