// // KBFansHeaderView.m // YouHuiProject // // Created by 小花 on 2018/5/19. // Copyright © 2018年 kuxuan. All rights reserved. // #import "KBFansHeaderView.h" @interface KBFansHeaderView() @property(nonatomic,strong)UIView *content; @property(nonatomic,strong)UILabel *title; @property(nonatomic,strong)UILabel *fansCount; @property(nonatomic,strong)UILabel *SVip; @property(nonatomic,strong)UILabel *vip; @end @interface KBFansHeaderView () @end @implementation KBFansHeaderView - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { self.backgroundColor = [UIColor yhGrayColor]; self.layer.cornerRadius = 6; [self initSubViews]; [self request]; } return self; } -(void)request{ NSString *url=[NSString stringWithFormat:@"%@/api/v2/adzoneCreate/fansNum",BaseURL]; [KBHttp post:url params:nil success:^(id json) { if (json[@"data"]) { self.fansCount.text =[NSString stringWithFormat:@"%@",json[@"data"][@"allNum"]]; self.SVip.text =[NSString stringWithFormat:@"直属粉丝:%@",json[@"data"][@"firstNum"]]; self.vip.text =[NSString stringWithFormat:@"推荐粉丝:%@",json[@"data"][@"secondNum"]]; } } failure:^(NSError *error) { }]; } - (void)initSubViews { self.content= [[UIView alloc] initWithFrame:CGRectMake(10, 10, self.width-20, self.height-20)]; self.content.backgroundColor = [UIColor changeColor]; [self addSubview:self.content]; _title= [[UILabel alloc] initWithFrame:CGRectMake(0, 15, self.content.width, 20)]; self.title.font = [UIFont systemFontOfSize:12]; self.title.textColor = [UIColor whiteColor]; self.title.text = @"粉丝数"; self.title.centerX = self.width/2; self.title.textAlignment = NSTextAlignmentCenter; [self.content addSubview:self.title]; self.fansCount= [[UILabel alloc] initWithFrame:CGRectMake(0, self.title.bottom+5, self.content.width, 40)]; self.fansCount.textColor = [UIColor whiteColor]; self.fansCount.font = [UIFont systemFontOfSize:32]; self.fansCount.textAlignment = NSTextAlignmentCenter; self.fansCount.text = @"----"; [self.content addSubview:self.fansCount]; self.SVip= [[UILabel alloc] initWithFrame:CGRectMake(10, self.content.height-17-20,self.content.width/2, 20)]; self.SVip.font = [UIFont systemFontOfSize:12]; self.SVip.textColor = [UIColor whiteColor]; self.SVip.text = @"直属粉丝:--"; [self.content addSubview:self.SVip]; self.vip= [[UILabel alloc] initWithFrame:CGRectMake(self.SVip.right, self.SVip.top, self.content.width/2-20, 20)]; self.vip.font = [UIFont systemFontOfSize:12]; self.vip.textAlignment = NSTextAlignmentRight; self.vip.textColor = [UIColor whiteColor]; self.vip.text = @"推荐粉丝:--"; [self.content addSubview:self.vip]; } @end