123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- //
- // RankCell.m
- // jiaPei
- //
- // Created by apple on 15/11/28.
- // Copyright (c) 2015年 JCZ. All rights reserved.
- //
- #import "RankCell.h"
- #import "UIImageView+WebCache.h"
- @implementation RankCell
- {
- UIImageView* honorIv;
- UILabel* indLbl;
- UILabel* scoLbl;
-
- UIImageView* headIv;
-
- }
- - (void)awakeFromNib {
- [super awakeFromNib];
- // Initialization code
- }
- - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
- [super setSelected:selected animated:animated];
- }
- -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
- {
- self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
- if (self)
- {
- indLbl = [[UILabel alloc] init];
- [self.contentView addSubview:indLbl];
- scoLbl = [[UILabel alloc] init];
- [self setAccessoryView:scoLbl];
- honorIv = [[UIImageView alloc] init];
- [self.contentView addSubview:honorIv];
- [honorIv setContentMode:UIViewContentModeScaleAspectFit];
- [indLbl setTextAlignment:NSTextAlignmentRight];
-
- headIv = [[UIImageView alloc] init];
-
- [indLbl setTextColor:contentTextColor];
- [self.textLabel setTextColor:kTitleColor];
- [self.detailTextLabel setTextColor:contentTextColor];
- [scoLbl setTextColor:[UIColor redColor]];
- }
- return self;
- }
- -(void)setModel:(NSDictionary *)model
- {
- //NSString *nickName = model[@""];
- //如果不通过 只能添加这个字段试试了
-
- [self.textLabel setText:model[@"EI_USERNAME"]];
- int num = [model[@"EI_TOTAL_TIME"] intValue];
- NSString* str = [NSString stringWithFormat:@"用时%d分%d秒",num/60,num%60];
- [self.detailTextLabel setText:str];
- str = [NSString stringWithFormat:@"%@分",model[@"EI_SCORE"]];
- [scoLbl setText:str];
-
- NSString *urlStr = model[@"USER_PHOTO"];
- if (urlStr && urlStr.length > 0) {
- [headIv sd_setImageWithURL:[NSURL URLWithString:urlStr] placeholderImage:[UIImage imageNamed:@"rankDefault"]];
- }
-
- }
- -(void)setIndex:(NSInteger)index
- {
- switch (index) {
- case 0:
- [honorIv setHidden:NO];
- [indLbl setHidden:YES];
- [honorIv setImage:[UIImage imageNamed:@"rank_first.png"]];
- // [headIv setColor:[UIColor redColor]];
- [self setBackgroundColor:RGB_COLOR(254, 236, 235)];
- break;
- case 1:
- [honorIv setHidden:NO];
- [indLbl setHidden:YES];
- // [headIv setColor:[UIColor orangeColor]];
- [honorIv setImage:[UIImage imageNamed:@"rank_second.png"]];
- [self setBackgroundColor:RGB_COLOR(254, 247, 232)];
- break;
- case 2:
- [honorIv setHidden:NO];
- [indLbl setHidden:YES];
- // [headIv setColor:defGreen];
- [honorIv setImage:[UIImage imageNamed:@"rank_third.png"]];
- [self setBackgroundColor:RGB_COLOR(239, 251, 232)];
- break;
- default:
- [indLbl setHidden:NO];
- [honorIv setHidden:YES];
- // [headIv setColor:nil];
- [self setBackgroundColor:[UIColor clearColor]];
- break;
- }
- [headIv setNeedsDisplay];
- [indLbl setText:[NSString stringWithFormat:@"%d",(int)index+1]];
- }
- -(void)layoutSubviews
- {
- [super layoutSubviews];
-
- CGFloat x,y,w,h,bd;
- w = 30;
- h = self.height;
- x = 20;
- y=0;
- [honorIv setFrame:CGRectMake(x, y, w, h)];
- [indLbl setFrame:CGRectMake(0, y, w+x, h)];
-
- bd = 10;
- x += w+15;
- y = bd;
- h = self.height - y;
- w = h;
- [headIv setFrame:CGRectMake(x, y, w, h)];
- headIv.layer.masksToBounds = YES;
- headIv.layer.cornerRadius = h/2;
- [self.contentView addSubview:headIv];
-
- x += w + 15;
- y = 0;
- w = self.width - x;
- h = self.height *.6;
- [self.textLabel setFrame:CGRectMake(x, y, w, h)];
-
- y = self.height * .4 + 4;
- h -= 8;
- [self.detailTextLabel setFrame:CGRectMake(x, y, w, h)];
-
- w = self.height;
- [scoLbl setFrame:CGRectMake(kSize.width-w, 5, w, w-5)];
- }
- +(CGFloat)cellHeight
- {
- return 60;
- }
- @end
|