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.
126 lines
4.8 KiB
126 lines
4.8 KiB
// |
|
// TFPopularityViewCell.m |
|
// TFReader |
|
// |
|
// Created by 谢腾飞 on 2020/12/17. |
|
// Copyright © 2020 xtfei_2011@126.com. All rights reserved. |
|
// |
|
|
|
#import "TFPopularityViewCell.h" |
|
|
|
@interface TFPopularityViewCell () |
|
|
|
@property (nonatomic ,strong) TFProductionCoverView *iconTop; |
|
@property (nonatomic ,strong) TFProductionCoverView *iconCenter; |
|
@property (nonatomic ,strong) TFProductionCoverView *iconBottom; |
|
@property (nonatomic ,strong) UILabel *rankLabel; |
|
@property (nonatomic ,strong) UILabel *descriptionLabel; |
|
|
|
@end |
|
|
|
@implementation TFPopularityViewCell |
|
|
|
- (void)createSubviews |
|
{ |
|
[super createSubviews]; |
|
|
|
self.iconBottom = [[TFProductionCoverView alloc] initWithProductionType:TFProductionTypeNovel coverDirection:TFProductionCoverDirectionVertical]; |
|
[self.contentView addSubview:self.iconBottom]; |
|
|
|
self.iconCenter = [[TFProductionCoverView alloc] initWithProductionType:TFProductionTypeNovel coverDirection:TFProductionCoverDirectionVertical]; |
|
[self.contentView addSubview:self.iconCenter]; |
|
|
|
self.iconTop = [[TFProductionCoverView alloc] initWithProductionType:TFProductionTypeNovel coverDirection:TFProductionCoverDirectionVertical]; |
|
[self.contentView addSubview:self.iconTop]; |
|
|
|
[self.iconTop mas_makeConstraints:^(MASConstraintMaker *make) { |
|
make.left.mas_equalTo(self.contentView.mas_left).with.offset(kHalfMargin); |
|
make.top.mas_equalTo(self.contentView.mas_top).with.offset(kHalfMargin); |
|
make.width.mas_equalTo(60); |
|
make.height.mas_equalTo(kGeometricHeight(60, 3, 4)); |
|
make.bottom.mas_equalTo(self.contentView.mas_bottom).with.offset(- kHalfMargin).priorityLow(); |
|
}]; |
|
|
|
[self.iconCenter mas_makeConstraints:^(MASConstraintMaker *make) { |
|
make.bottom.mas_equalTo(self.iconTop.mas_bottom); |
|
make.right.mas_equalTo(self.iconTop.mas_right).with.offset(kMargin); |
|
make.width.mas_equalTo(50); |
|
make.height.mas_equalTo(kGeometricHeight(50, 3, 4)); |
|
}]; |
|
|
|
[self.iconBottom mas_makeConstraints:^(MASConstraintMaker *make) { |
|
make.bottom.mas_equalTo(self.iconCenter.mas_bottom); |
|
make.right.mas_equalTo(self.iconCenter.mas_right).with.offset(kMargin); |
|
make.width.mas_equalTo(40); |
|
make.height.mas_equalTo(kGeometricHeight(40, 3, 4)); |
|
}]; |
|
|
|
self.rankLabel = [[UILabel alloc] init]; |
|
self.rankLabel.textColor = kBlackColor; |
|
self.rankLabel.backgroundColor = kGrayViewColor; |
|
self.rankLabel.font = kMainFont; |
|
[self.contentView addSubview:self.rankLabel]; |
|
|
|
[self.rankLabel mas_makeConstraints:^(MASConstraintMaker *make) { |
|
make.bottom.mas_equalTo(self.iconTop.mas_centerY).with.offset(- 2); |
|
make.left.mas_equalTo(self.iconBottom.mas_right).with.offset(kMargin); |
|
make.right.mas_equalTo(self.contentView.mas_right).with.offset(- kHalfMargin); |
|
make.height.mas_equalTo(30); |
|
}]; |
|
|
|
self.descriptionLabel = [[UILabel alloc] init]; |
|
self.descriptionLabel.textColor = kGrayTextColor; |
|
self.descriptionLabel.backgroundColor = kGrayViewColor; |
|
self.descriptionLabel.font = kFont12; |
|
[self.contentView addSubview:self.descriptionLabel]; |
|
|
|
[self.descriptionLabel mas_makeConstraints:^(MASConstraintMaker *make) { |
|
make.top.mas_equalTo(self.iconTop.mas_centerY).with.offset(2); |
|
make.left.mas_equalTo(self.rankLabel.mas_left); |
|
make.width.mas_equalTo(self.rankLabel.mas_width); |
|
make.height.mas_equalTo(self.rankLabel.mas_height); |
|
}]; |
|
} |
|
|
|
- (void)setRankListModel:(TFPopularityModel *)rankListModel |
|
{ |
|
_rankListModel = rankListModel; |
|
|
|
for (int i = 0; i < rankListModel.icon.count; i++) { |
|
switch (i) { |
|
case 0: |
|
self.iconTop.coverImageUrl = [rankListModel.icon objectOrNilAtIndex:0]; |
|
break; |
|
case 1: |
|
self.iconCenter.coverImageUrl = [rankListModel.icon objectOrNilAtIndex:1]; |
|
if ([rankListModel.icon objectAtIndex:1].length <= 0) { |
|
self.iconCenter.hidden = YES; |
|
} |
|
break; |
|
case 2: |
|
self.iconBottom.coverImageUrl = [rankListModel.icon objectOrNilAtIndex:2]; |
|
if ([rankListModel.icon objectAtIndex:2].length <= 0) { |
|
self.iconBottom.hidden = YES; |
|
} |
|
break; |
|
|
|
default: |
|
break; |
|
} |
|
} |
|
|
|
self.rankLabel.backgroundColor = [UIColor whiteColor]; |
|
self.rankLabel.text = rankListModel.list_name?:@""; |
|
|
|
self.descriptionLabel.backgroundColor = [UIColor whiteColor]; |
|
self.descriptionLabel.text = rankListModel.rankDescription?:@""; |
|
} |
|
|
|
- (void)setProductionType:(TFProductionType)productionType |
|
{ |
|
[super setProductionType:productionType]; |
|
|
|
self.iconTop.productionType = productionType; |
|
} |
|
|
|
@end
|
|
|