123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- //
- // DRAchievementView.m
- // YouHuiProject
- //
- // Created by 小花 on 2018/8/2.
- // Copyright © 2018年 kuxuan. All rights reserved.
- //
- #import "DRAchievementView.h"
- @interface DRAchievementView (){
- NSArray *_buttons;
- NSString *_title;
- }
- @end
- @implementation DRAchievementView
- - (instancetype)initWithFrame:(CGRect)frame titleInfoArray:(NSArray *)array title:(NSString *)title{
- self = [super initWithFrame:frame];
- if (self) {
- _title = title;
- _buttons = array;
- self.backgroundColor = [UIColor whiteColor];
- self.layer.cornerRadius = 6;
- [self initSubViews];
- // self.layer.shadowColor = [UIColor homeRedColor].CGColor;
- // self.layer.shadowOffset = CGSizeMake(0, 0);
- // self.layer.shadowOpacity = 0.3;
- // self.layer.shadowRadius = 3;
- }
- return self;
- }
- - (void)initSubViews {
-
- UILabel *titleLb = [[UILabel alloc] initWithFrame:CGRectMake(15, 0, 200, Fitsize(36))];
- titleLb.font = [UIFont systemFontOfSize:Fitsize(14)];
- titleLb.textColor = [UIColor YHColorWithHex:0x000000];
- titleLb.text = _title;
- [self addSubview:titleLb];
-
- UILabel *Line = [[UILabel alloc] initWithFrame:CGRectMake(5, titleLb.bottom, self.width-10, 1)];
- Line.backgroundColor = [UIColor yhGrayColor];
- [self addSubview:Line];
-
- CGFloat width = self.width/4;
- CGFloat height = Fitsize(20);
-
- for (int i = 0; i < _buttons.count; i++) {
-
- UIView *bg = [[UIView alloc] initWithFrame:CGRectMake(width * (i%4), Line.bottom+(i/4)*height, width, width)];
- bg.tag = 1000+i;
- UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapViewAction:)];
- [bg addGestureRecognizer:tap];
- [self addSubview:bg];
-
- UILabel *detailLb = [[UILabel alloc] initWithFrame:CGRectMake(width * (i%4),Line.bottom+Fitsize(20)+ (i/4)*height, width, height)];
- detailLb.text = @"--";
- detailLb.font = [UIFont boldSystemFontOfSize:Fitsize(16)];
- detailLb.textAlignment = NSTextAlignmentCenter;
- detailLb.textColor = [UIColor homeRedColor];
- detailLb.tag = 10000 + i;
- [self addSubview:detailLb];
-
- UILabel *title = [[UILabel alloc] initWithFrame:CGRectMake(width * (i%4),detailLb.bottom+Fitsize(10), width, height)];
- title.text = _buttons[i];
- title.textColor = [UIColor YHColorWithHex:0x7c7c7c];
- title.font = [UIFont systemFontOfSize:Fitsize(12)];
- title.textAlignment = NSTextAlignmentCenter;
- [self addSubview:title];
-
- }
- NSInteger row = _buttons.count/4;
- if (_buttons.count%4 != 0) {
- row += 1;
- }
- self.height = Line.bottom + row * width;
- }
- - (void)tapViewAction:(UITapGestureRecognizer *)tap {
- NSInteger index = tap.view.tag - 1000;
- if (self.tapMenuBlock) {
- self.tapMenuBlock(index);
- }
- }
- - (void)setUserInfo:(DRUserInfo *)userInfo {
- if (userInfo) {
- NSString *this_day_order_count = userInfo.this_day_order_count==nil?@"--":userInfo.this_day_order_count;
- NSString *this_day_forecast_income = userInfo.this_day_order_count==nil?@"--":userInfo.this_day_forecast_income;
- NSString *register_friends = userInfo.this_day_order_count==nil?@"--":userInfo.register_friends;
- NSString *no_register_friends = userInfo.this_day_order_count==nil?@"--":userInfo.no_register_friends;
-
- NSArray *infoArr = @[this_day_order_count,
- this_day_forecast_income,
- register_friends,
- no_register_friends];
- for (int i = 0; i < infoArr.count; i++) {
- UILabel *detailLb = [self viewWithTag:10000+i];
- detailLb.text = infoArr[i];
- }
- }
-
- }
- @end
|