// // KBAccountHeader.m // YouHuiProject // // Created by 小花 on 2018/6/8. // Copyright © 2018年 kuxuan. All rights reserved. // #import "KBAccountHeader.h" @interface KBAccountHeader(){ UILabel *_blanceLabel; NSString *_blance; } @end @implementation KBAccountHeader - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { self.backgroundColor = [UIColor changeColor]; [self initSubViews]; [self request]; } return self; } - (void)initSubViews { UILabel *title = [[UILabel alloc] initWithFrame:CGRectMake(25, 10, 200, 20)]; title.text = @"账户余额:"; title.font = [UIFont systemFontOfSize:14]; title.textColor = [UIColor whiteColor]; [self addSubview:title]; _blanceLabel = [[UILabel alloc] initWithFrame:CGRectMake(25, title.bottom+10, 200, 30)]; _blanceLabel.textColor = [UIColor whiteColor]; _blanceLabel.font = [UIFont boldSystemFontOfSize:35]; _blanceLabel.text = @"--.--"; [self addSubview:_blanceLabel]; UIButton *money = [[UIButton alloc] initWithFrame:CGRectMake(self.width-20-40, 40, 40, 30)]; [money setTitle:@"提现" forState:UIControlStateNormal]; [money setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; money.titleLabel.font = [UIFont systemFontOfSize:14]; [self addSubview:money]; [money addTarget:self action:@selector(moneyAction) forControlEvents:UIControlEventTouchUpInside]; } - (void)moneyAction { if (self.moneyBackBlcok) { self.moneyBackBlcok(_blance); } } - (void)request{ NSString *url=[NSString stringWithFormat:@"%@/api/v2/adzoneCreate/accountPrice",BaseURL]; [KBHttp post:url params:nil success:^(id json) { if (json[@"data"]) { _blance = [NSString stringWithFormat:@"%@",json[@"data"][@"notEnd"]]; _blanceLabel.text = [NSString stringWithFormat:@"¥%@",_blance]; } } failure:^(NSError *error) { }]; } @end