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.

112 lines
4.3 KiB

//
// TFDiscoverComicViewCell.m
// TFReader
//
// Created by 谢腾飞 on 2020/12/16.
// Copyright © 2020 xtfei_2011@126.com. All rights reserved.
//
#import "TFDiscoverComicViewCell.h"
#import "TFTagboardView.h"
@interface TFDiscoverComicViewCell ()
@property (nonatomic ,strong) UIImageView *coverView;
@property (nonatomic ,strong) UILabel *titleLabel;
@property (nonatomic ,strong) UILabel *flagLabel;
@property (nonatomic ,strong) TFTagboardView *tagboardView;
@end
@implementation TFDiscoverComicViewCell
- (void)createSubviews
{
[super createSubviews];
self.coverView = [[UIImageView alloc] initWithCornerRadiusAdvance:8 rectCornerType:UIRectCornerAllCorners];
self.coverView.frame = CGRectMake(kHalfMargin, kHalfMargin, SCREEN_WIDTH - kMargin, kGeometricHeight(SCREEN_WIDTH - kMargin, 7, 4));
self.coverView.image = HoldImage;
self.coverView.layer.shadowColor = [UIColor blackColor].CGColor;
self.coverView.layer.shadowOffset = CGSizeMake(0, 0);
self.coverView.layer.shadowOpacity = 0.1f;
self.coverView.layer.shadowRadius = 2.0f;
self.coverView.contentMode = UIViewContentModeScaleAspectFill;
[self.coverView.layer setShadowPath:[[UIBezierPath bezierPathWithRect:self.coverView.bounds] CGPath]];
[self.contentView addSubview:self.coverView];
self.titleLabel = [[UILabel alloc] init];
self.titleLabel.textColor = kBlackColor;
self.titleLabel.textAlignment = NSTextAlignmentLeft;
self.titleLabel.font = kMainFont;
[self.contentView addSubview:self.titleLabel];
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(kHalfMargin);
make.top.mas_equalTo(self.coverView.height + kHalfMargin + kHalfMargin);
make.height.mas_equalTo(20);
make.width.mas_equalTo(20);
}];
// 标签
self.tagboardView = [[TFTagboardView alloc] init];
self.tagboardView.font = kFont10;
self.tagboardView.cornerRadius = 4;
[self.contentView addSubview:self.tagboardView];
[self.tagboardView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.titleLabel.mas_right).with.offset(kHalfMargin);
make.centerY.mas_equalTo(self.titleLabel.mas_centerY);
make.right.mas_equalTo(self.contentView.mas_right).with.offset(-kHalfMargin);
make.height.mas_equalTo(20);
}];
self.flagLabel = [[UILabel alloc] init];
self.flagLabel.textColor = kGrayTextColor;
self.flagLabel.textAlignment = NSTextAlignmentLeft;
self.flagLabel.font = kFont11;
[self.contentView addSubview:self.flagLabel];
[self.flagLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.titleLabel.mas_left);
make.top.mas_equalTo(self.titleLabel.mas_bottom).with.offset(kQuarterMargin);
make.right.mas_equalTo(self.contentView.mas_right).with.offset(-kHalfMargin);
make.height.mas_equalTo(15);
make.bottom.mas_equalTo(self.contentView.mas_bottom).with.offset(-kQuarterMargin).priorityLow();
}];
}
- (void)setDiscoverComic:(TFProductionModel *)discoverComic
{
_discoverComic = discoverComic;
[self.coverView setImageWithURL:[NSURL URLWithString:discoverComic.cover ? : @""] placeholder:HoldImage options:YYWebImageOptionSetImageWithFadeAnimation completion:nil];
self.titleLabel.text = discoverComic.name ? : @"";
[self.titleLabel mas_updateConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo([TFViewHelper getDynamicWidthWithLabel:self.titleLabel]);
}];
if (discoverComic.flag.length > 0) {
self.flagLabel.text = discoverComic.flag ? : @"";
[self.flagLabel mas_updateConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(15);
make.bottom.mas_equalTo(self.contentView.mas_bottom).with.offset(-kQuarterMargin).priorityLow();
}];
} else {
[self.flagLabel mas_updateConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(CGFLOAT_MIN);
make.bottom.mas_equalTo(self.contentView.mas_bottom).priorityLow();
}];
}
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
self.tagboardView.tagboardArray = discoverComic.tag;
});
}
@end