// // MyTeamHeader.m // model // // Created by Drew on 2018/10/29. // Copyright © 2018 Mine. All rights reserved. // #import "MyTeamHeader.h" @interface MyTeamHeader() @property (weak, nonatomic) IBOutlet UIView *content; @property (weak, nonatomic) IBOutlet UILabel *inviteLabel; @property (weak, nonatomic) IBOutlet UILabel *rewardLabel; @property (weak, nonatomic) IBOutlet UILabel *labelAuth; @property (weak, nonatomic) IBOutlet UILabel *labelAuthed; @property (weak, nonatomic) IBOutlet UIView *coinView; @end @implementation MyTeamHeader - (instancetype)initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { [self initView]; } return self; } - (instancetype)initWithCoder:(NSCoder *)aDecoder { if (self = [super initWithCoder:aDecoder]) { [self initView]; } return self; } - (void) initView { NSBundle *bundle = [NSBundle bundleForClass:[self class]]; NSString *className = NSStringFromClass([self class]); UIView *view = [[bundle loadNibNamed:className owner:self options:nil] firstObject]; view.frame = self.bounds; [self addSubview:view]; self.content.clipsToBounds = YES; } - (void)layoutSubviews { [super layoutSubviews]; // gradient CAGradientLayer *gl = [CAGradientLayer layer]; gl.frame = CGRectMake(0, 0, ScreenWidth - 40, self.bounds.size.height - 22); gl.startPoint = CGPointMake(0.03, 0.47); gl.endPoint = CGPointMake(0.97, 0.47); 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]; gl.locations = @[@(0), @(1.0f)]; self.content.layer.cornerRadius = 12; [self.content.layer insertSublayer:gl atIndex:0]; } - (void)setType:(NSString *)type { _type = type; if ([@"model" isEqualToString:type]) { self.coinView.hidden = YES; self.labelAuth.hidden = NO; self.labelAuthed.hidden = YES; } else { self.coinView.hidden = NO; self.labelAuth.hidden = YES; self.labelAuthed.hidden = YES; } } - (void)setIntroduceNum:(NSString*)introduceNum { _introduceNum = introduceNum; self.inviteLabel.text = introduceNum; if ([@"model" isEqualToString:self.type] && [introduceNum intValue] >= 9) { self.coinView.hidden = NO; self.labelAuth.hidden = YES; self.labelAuthed.hidden = NO; } } - (void)setTotalCoin:(NSString*)totalCoin { _totalCoin = totalCoin; self.rewardLabel.text = totalCoin; } @end