You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
156 lines
5.8 KiB
156 lines
5.8 KiB
// |
|
// RankingListHeadView.m |
|
// tongxin |
|
// |
|
// Created by WeiChaoZheng on 2018/8/24. |
|
// Copyright © 2018年 xTT. All rights reserved. |
|
// |
|
|
|
#import "RankingListHeadView.h" |
|
#import "Step.h" |
|
|
|
@implementation RankingListHeadView |
|
|
|
+ (instancetype)viewFirstXib |
|
{ |
|
NSArray * array = [[NSBundle mainBundle] loadNibNamed:@"RankingListHeadView" owner:nil options:nil]; |
|
return [array firstObject]; |
|
} |
|
|
|
- (void)awakeFromNib { |
|
[super awakeFromNib]; |
|
// Initialization code |
|
// self.firstView.transform = CGAffineTransformMakeScale(1.1, 1.1); |
|
self.firstStepLabel.textColor = mainColor; |
|
self.firstView.hidden = YES; |
|
// self.secondView.transform = CGAffineTransformMakeScale(0.9, 0.9); |
|
self.secondStepLabel.textColor = mainColor; |
|
self.secondView.hidden = YES; |
|
// self.thirdView.transform = CGAffineTransformMakeScale(0.9, 0.9); |
|
self.thirdStepLabel.textColor = mainColor; |
|
self.thirdView.hidden = YES; |
|
|
|
} |
|
-(void)layoutSubviews{ |
|
self.firstDeviceImageView.layer.cornerRadius = self.firstDeviceImageView.frame.size.width/2; |
|
self.secondDeviceImageView.layer.cornerRadius = self.secondDeviceImageView.frame.size.width/2; |
|
self.thirdDeviceImageView.layer.cornerRadius = self.thirdDeviceImageView.frame.size.width/2; |
|
self.firstDeviceImageView.layer.masksToBounds = YES; |
|
self.secondDeviceImageView.layer.masksToBounds = YES; |
|
self.thirdDeviceImageView.layer.masksToBounds = YES; |
|
} |
|
-(void)setDataWithListHead:(NSArray<Step*>*)stepArr{ |
|
|
|
|
|
if(stepArr && stepArr.count> 0){ |
|
for (int i = 0; i < stepArr.count; i++) { |
|
if(i == 0){ |
|
//根据男女区分 |
|
NSString *icon = @""; |
|
if([stepArr[0].sex isEqualToString:@"girl"]){ |
|
icon = @"icon_girl_head_portrait_1"; |
|
}else{ |
|
icon = @"icon_boy_head_portrait_1"; |
|
} |
|
self.firstNameLabel.text = stepArr[0].name; |
|
if (stepArr[0].avator && ![stepArr[0].avator containsString:@"/default.jpg"]) { |
|
[self.firstDeviceImageView sd_setImageWithURL:[NSURL URLWithString:stepArr[0].avator]placeholderImage:[UIImage imageNamed:icon]]; |
|
} else { |
|
self.firstDeviceImageView.image = [UIImage imageNamed:icon]; |
|
} |
|
self.firstStepLabel.text = [NSString stringWithFormat:@"%@步",stepArr[0].num]; |
|
|
|
self.firstView.hidden = NO; |
|
} |
|
|
|
if(i == 1){ |
|
//根据男女区分 |
|
NSString *icon = @""; |
|
if([stepArr[1].sex isEqualToString:@"girl"]){ |
|
icon = @"icon_girl_head_portrait_1"; |
|
}else{ |
|
icon = @"icon_boy_head_portrait_1"; |
|
} |
|
self.secondNameLabel.text = stepArr[1].name; |
|
self.secondStepLabel.text = [NSString stringWithFormat:@"%@步",stepArr[1].num]; |
|
if (stepArr[1].avator && ![stepArr[1].avator containsString:@"/default.jpg"]) { |
|
[self.secondDeviceImageView sd_setImageWithURL:[NSURL URLWithString:stepArr[1].avator] placeholderImage:[UIImage imageNamed:icon]]; |
|
} else { |
|
|
|
self.secondDeviceImageView.image = [UIImage imageNamed:icon]; |
|
} |
|
self.secondView.hidden = NO; |
|
} |
|
|
|
if(i == 2){ |
|
//根据男女区分 |
|
NSString *icon = @""; |
|
if([stepArr[2].sex isEqualToString:@"girl"]){ |
|
icon = @"icon_girl_head_portrait_1"; |
|
}else{ |
|
icon = @"icon_boy_head_portrait_1"; |
|
} |
|
self.thirdNameLabel.text = stepArr[2].name; |
|
self.thirdStepLabel.text = [NSString stringWithFormat:@"%@步",stepArr[2].num]; |
|
if (stepArr[2].avator && ![stepArr[2].avator containsString:@"/default.jpg"]) { |
|
[self.thirdDeviceImageView sd_setImageWithURL:[NSURL URLWithString:stepArr[2].avator] placeholderImage:[UIImage imageNamed:icon]]; |
|
} else { |
|
self.thirdDeviceImageView.image = [UIImage imageNamed:icon]; |
|
} |
|
self.thirdView.hidden = NO; |
|
} |
|
} |
|
//计步的 列表显示 |
|
switch (stepArr.count) { |
|
case 0: |
|
self.firstView.hidden = YES; |
|
self.secondView.hidden = YES; |
|
self.thirdView.hidden = YES; |
|
break; |
|
case 1: |
|
self.firstView.hidden = NO; |
|
self.secondView.hidden = YES; |
|
self.thirdView.hidden = YES; |
|
break; |
|
case 2: |
|
self.firstView.hidden = NO; |
|
self.secondView.hidden = NO; |
|
self.thirdView.hidden = YES; |
|
break; |
|
case 3: |
|
self.firstView.hidden = NO; |
|
self.secondView.hidden = NO; |
|
self.thirdView.hidden = NO; |
|
break; |
|
|
|
default: |
|
break; |
|
} |
|
}else{ |
|
//如果是 空的 都要隐藏 |
|
self.firstView.hidden = YES; |
|
self.secondView.hidden = YES; |
|
self.thirdView.hidden = YES; |
|
} |
|
} |
|
|
|
//-(void)setImageView:(UIImageView*)imageView WithStepModel:(Step*)data{ |
|
// if(data.avator && ![data.avator containsString:@"default.jpg"]){ |
|
// [imageView sd_setImageWithURL:[NSURL URLWithString:data.avator]]; |
|
// }else{ |
|
// //判断性别 |
|
// NSString *sexImageName ; |
|
// if([data.sex isEqualToString:@"girl"]){ |
|
// //女 |
|
// sexImageName = @"icon_girl_head_portrait_1"; |
|
// }else{ |
|
// //男 |
|
// sexImageName = @"icon_boy_head_portrait_1"; |
|
// } |
|
// imageView.image = [UIImage imageNamed:sexImageName]; |
|
// } |
|
//} |
|
|
|
|
|
|
|
@end
|
|
|