MyTeamHeader.m 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. @end
  14. @implementation MyTeamHeader
  15. - (instancetype)initWithFrame:(CGRect)frame {
  16. if (self = [super initWithFrame:frame]) {
  17. [self initView];
  18. }
  19. return self;
  20. }
  21. - (instancetype)initWithCoder:(NSCoder *)aDecoder {
  22. if (self = [super initWithCoder:aDecoder]) {
  23. [self initView];
  24. }
  25. return self;
  26. }
  27. - (void) initView {
  28. NSBundle *bundle = [NSBundle bundleForClass:[self class]];
  29. NSString *className = NSStringFromClass([self class]);
  30. UIView *view = [[bundle loadNibNamed:className owner:self options:nil] firstObject];
  31. view.frame = self.bounds;
  32. [self addSubview:view];
  33. self.content.clipsToBounds = YES;
  34. }
  35. - (void)layoutSubviews {
  36. [super layoutSubviews];
  37. // gradient
  38. CAGradientLayer *gl = [CAGradientLayer layer];
  39. gl.frame = self.content.bounds;
  40. gl.startPoint = CGPointMake(0.03, 0.47);
  41. gl.endPoint = CGPointMake(0.97, 0.47);
  42. 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];
  43. gl.locations = @[@(0), @(1.0f)];
  44. self.content.layer.cornerRadius = 12;
  45. [self.content.layer insertSublayer:gl atIndex:0];
  46. }
  47. @end