// // WodeUserAssetCell.m // Ifish // // Created by imac on 17/3/20. // Copyright © 2017年 lianlian. All rights reserved. // #import "WodeUserAssetCell.h" @implementation WodeUserAssetCell -(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{ self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { CGFloat WiD = (kScreenSize.width - 2) /3; //等级 UILabel *dengJi = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, WiD, 30)]; dengJi.text =@"等级"; dengJi.textColor = [UIColor whiteColor]; dengJi.textAlignment = NSTextAlignmentCenter; dengJi.font = [UIFont systemFontOfSize:14.0]; self.dengJi = dengJi; self.dengJi.userInteractionEnabled = YES; [self addSubview:self.dengJi]; UILabel *levlellabel=[[UILabel alloc] initWithFrame:CGRectMake(0,30, WiD, 30)];; levlellabel.textColor = RGB(252, 217, 94); levlellabel.textAlignment = NSTextAlignmentCenter; levlellabel.font = [UIFont systemFontOfSize:14.0]; self.levlellabel = levlellabel; self.levlellabel.userInteractionEnabled = YES; [self addSubview:self.levlellabel]; //line1 UIView *line1= [[UIView alloc] initWithFrame:CGRectMake(CGRectGetMaxX(self.dengJi.frame), 13, 1, 60 -13*2)]; line1.backgroundColor = RGB(12, 118, 217); line1.alpha = 0.7; [self addSubview:line1]; //金币 UILabel *jinBi = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(line1.frame),0, WiD, 30)]; jinBi.text =@"金币"; jinBi.textColor = [UIColor whiteColor]; jinBi.textAlignment = NSTextAlignmentCenter; jinBi.font = [UIFont systemFontOfSize:14.0]; self.jinBi = jinBi; self.jinBi.userInteractionEnabled = YES; [self addSubview:self.jinBi]; UILabel *goldLabel=[[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(line1.frame),30, WiD, 30)];; goldLabel.textColor = RGB(252, 217, 94); goldLabel.textAlignment = NSTextAlignmentCenter; goldLabel.font = [UIFont systemFontOfSize:14.0]; self.goldLabel = goldLabel; self.goldLabel.userInteractionEnabled = YES; [self addSubview:self.goldLabel]; //line2 UIView *line2= [[UIView alloc] initWithFrame:CGRectMake(CGRectGetMaxX(self.jinBi.frame), 13, 1, 60 -13*2)]; line2.backgroundColor = RGB(12, 118, 217); line2.alpha = 0.7; [self addSubview:line2]; // 任务 UILabel *renWu = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(line2.frame),0, WiD, 30)]; renWu.text =@"我的任务"; renWu.textColor = [UIColor whiteColor]; renWu.textAlignment = NSTextAlignmentCenter; renWu.font = [UIFont systemFontOfSize:14.0]; self.renWu = renWu; self.renWu.userInteractionEnabled = YES; [self addSubview:self.renWu]; self.redpontView = [[UIView alloc] init]; NSString *renwu= @"我的任务"; CGSize size = [renwu sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14]}]; self.redpontView.frame = CGRectMake(WiD/2 + size.width/2, 4, 8, 8); self.redpontView.backgroundColor = RGB(252, 89, 89); self.redpontView.layer.masksToBounds = YES; self.redpontView.layer.cornerRadius = 4.0; [self.renWu addSubview:self.redpontView]; UILabel *taskNumber=[[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(line2.frame),30, WiD, 30)];; taskNumber.textColor = RGB(252, 217, 94); taskNumber.textAlignment = NSTextAlignmentCenter; taskNumber.font = [UIFont systemFontOfSize:14.0]; self.taskNumber = taskNumber; self.taskNumber.userInteractionEnabled = YES; [self addSubview:self.taskNumber]; [self addTapGesture]; } return self; } -(void)addTapGesture{ UITapGestureRecognizer *tapDengji=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dengjiAction)]; UITapGestureRecognizer *tapDengji2=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dengjiAction2)]; [self.dengJi addGestureRecognizer:tapDengji]; [self.levlellabel addGestureRecognizer:tapDengji2]; UITapGestureRecognizer *tapgold=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapGoldAction)]; [self.goldLabel addGestureRecognizer:tapgold]; UITapGestureRecognizer *tapgold2=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapGoldAction2)]; [self.jinBi addGestureRecognizer:tapgold2]; UITapGestureRecognizer *tapRenWu=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapRenWuAction)]; UITapGestureRecognizer *tapRenWu2=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapRenWuAction2)]; [self.renWu addGestureRecognizer:tapRenWu]; [self.taskNumber addGestureRecognizer:tapRenWu2]; } -(void)dengjiAction { if (self.itemsDelegate) { [self.itemsDelegate tapDengjiAction]; } } -(void)dengjiAction2 { if (self.itemsDelegate) { [self.itemsDelegate tapDengjiAction]; } } -(void)tapGoldAction { if (self.itemsDelegate) { [self.itemsDelegate tapGoldAction]; } } -(void)tapGoldAction2 { if (self.itemsDelegate) { [self.itemsDelegate tapGoldAction]; } } -(void)tapRenWuAction { if (self.itemsDelegate) { [self.itemsDelegate tapRenWuAction]; } } -(void)tapRenWuAction2 { if (self.itemsDelegate) { [self.itemsDelegate tapRenWuAction]; } } - (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; // Configure the view for the selected state } -(void)loadCellData{ IfishUserAsset *userAsset =[dataContorl getAllIfishUserAsset]; self.levlellabel.text = [NSString stringWithFormat:@"LV%@",userAsset.gradeNum]; self.goldLabel.text = [NSString stringWithFormat:@"%ld",(long)userAsset.goldValue]; NSInteger undoneCount = [IfishHelperUtils getUnDoneTaskCount]; self.taskNumber.text = [NSString stringWithFormat:@"%ld",undoneCount]; self.redpontView.hidden = undoneCount ==0? YES : NO; if (undoneCount==0) { [[NSNotificationCenter defaultCenter] postNotificationName:IFISHTASK_HAVEDONEALL object:nil]; } } @end