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.
195 lines
6.3 KiB
195 lines
6.3 KiB
// |
|
// TFProductionCoverView.m |
|
// TFReader |
|
// |
|
// Created by 谢腾飞 on 2020/12/18. |
|
// Copyright © 2020 xtfei_2011@126.com. All rights reserved. |
|
// |
|
|
|
#import "TFProductionCoverView.h" |
|
|
|
@interface TFProductionCoverView () |
|
|
|
@property (nonatomic ,strong) UIView *shadowView; |
|
@property (nonatomic ,strong) UIImageView *productionView; |
|
@property (nonatomic ,strong) UIImageView *bottomTitleView; |
|
@property (nonatomic ,strong) UILabel *bottomTitleLabel; |
|
@property (nonatomic ,strong) UIView *lockView; |
|
@property (nonatomic ,strong) UIImageView *lockIconView; |
|
@property (nonatomic ,strong) UIImageView *connerView; |
|
|
|
@end |
|
|
|
@implementation TFProductionCoverView |
|
|
|
- (instancetype)initWithProductionType:(TFProductionType)type coverDirection:(TFProductionCoverDirection)direction |
|
{ |
|
if (self = [super init]) { |
|
|
|
self.productionType = type; |
|
self.coverDirection = direction; |
|
|
|
[self createSubview]; |
|
} |
|
return self; |
|
} |
|
|
|
- (void)createSubview |
|
{ |
|
// 背景阴影 |
|
self.shadowView = [[UIView alloc] init]; |
|
self.shadowView.backgroundColor = [UIColor whiteColor]; |
|
self.shadowView.layer.shadowColor = [UIColor blackColor].CGColor; |
|
self.shadowView.layer.shadowOffset = CGSizeMake(0, 0); |
|
self.shadowView.layer.shadowOpacity = 0.2f; |
|
self.shadowView.layer.shadowRadius = 2.0f; |
|
self.shadowView.userInteractionEnabled = YES; |
|
[self addSubview:self.shadowView]; |
|
|
|
// 作品图片 |
|
self.productionView = [[UIImageView alloc] init]; |
|
self.productionView.contentMode = UIViewContentModeScaleAspectFill; |
|
self.productionView.clipsToBounds = YES; |
|
self.productionView.userInteractionEnabled = YES; |
|
[self addSubview:self.productionView]; |
|
[self resetDefaultHoldImage]; |
|
|
|
// 有声增加左下角标志 |
|
self.connerView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"audio_conner_image"]]; |
|
self.connerView.userInteractionEnabled = YES; |
|
self.connerView.hidden = (self.productionType != TFProductionTypeAudio); |
|
[self addSubview:self.connerView]; |
|
|
|
// 漫画锁标志 |
|
self.lockView = [[UIView alloc] init]; |
|
self.lockView.userInteractionEnabled = YES; |
|
self.lockView.backgroundColor = kBlackTransparentColor; |
|
self.lockView.hidden = YES; |
|
[self addSubview:self.lockView]; |
|
|
|
self.lockIconView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"comic_lock"]]; |
|
[self.lockView addSubview:self.lockIconView]; |
|
|
|
// 漫画底部标题背景 |
|
self.bottomTitleView = [[UIImageView alloc] init]; |
|
self.bottomTitleView.hidden = YES; |
|
self.bottomTitleView.image = [UIImage imageNamed:@"comic_botton_line"]; |
|
[self addSubview:self.bottomTitleView]; |
|
|
|
// 漫画底部标题 |
|
self.bottomTitleLabel = [[UILabel alloc] init]; |
|
self.bottomTitleLabel.hidden = YES; |
|
self.bottomTitleLabel.textColor = [UIColor whiteColor]; |
|
self.bottomTitleLabel.textAlignment = NSTextAlignmentRight; |
|
self.bottomTitleLabel.backgroundColor = [UIColor clearColor]; |
|
self.bottomTitleLabel.font = kFont12; |
|
[self addSubview:self.bottomTitleLabel]; |
|
} |
|
|
|
- (void)layoutSubviews |
|
{ |
|
[super layoutSubviews]; |
|
|
|
[self.shadowView mas_makeConstraints:^(MASConstraintMaker *make) { |
|
make.centerX.mas_equalTo(self.mas_centerX); |
|
make.centerY.mas_equalTo(self.mas_centerY); |
|
make.width.mas_equalTo(self.mas_width).with.offset(- 2); |
|
make.height.mas_equalTo(self.mas_height).with.offset(- 2); |
|
}]; |
|
|
|
[self.productionView mas_makeConstraints:^(MASConstraintMaker *make) { |
|
make.edges.mas_equalTo(self.shadowView); |
|
}]; |
|
|
|
[self.connerView mas_makeConstraints:^(MASConstraintMaker *make) { |
|
make.left.mas_equalTo(self.productionView.mas_left).with.offset(kQuarterMargin); |
|
make.bottom.mas_equalTo(self.productionView.mas_bottom).with.offset(-kQuarterMargin); |
|
make.width.height.mas_equalTo(self.productionView.mas_width).with.multipliedBy(0.15); |
|
}]; |
|
|
|
[self.lockView mas_makeConstraints:^(MASConstraintMaker *make) { |
|
make.edges.mas_equalTo(self.productionView); |
|
}]; |
|
|
|
[self.lockIconView mas_makeConstraints:^(MASConstraintMaker *make) { |
|
make.width.height.mas_equalTo(12); |
|
make.centerX.mas_equalTo(self.lockView.mas_centerX); |
|
make.centerY.mas_equalTo(self.lockView.mas_centerY); |
|
}]; |
|
|
|
[self.bottomTitleView mas_makeConstraints:^(MASConstraintMaker *make) { |
|
make.left.mas_equalTo(self.productionView.mas_left); |
|
make.bottom.mas_equalTo(self.productionView.mas_bottom); |
|
make.width.mas_equalTo(self.productionView.mas_width); |
|
make.height.mas_equalTo(40); |
|
}]; |
|
|
|
[self.bottomTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) { |
|
make.left.mas_equalTo(self.productionView.mas_left); |
|
make.bottom.mas_equalTo(self.productionView.mas_bottom); |
|
make.right.mas_equalTo(self.productionView.mas_right).mas_offset(-kQuarterMargin); |
|
make.height.mas_equalTo(25); |
|
}]; |
|
} |
|
|
|
// 重置为默认图 |
|
- (void)resetDefaultHoldImage |
|
{ |
|
if (self.coverDirection == TFProductionCoverDirectionHorizontal) { |
|
self.productionView.image = HoldImage; |
|
} |
|
|
|
if (self.coverDirection == TFProductionCoverDirectionVertical) { |
|
self.productionView.image = HoldImage; |
|
} |
|
} |
|
|
|
- (void)setIs_locked:(BOOL)is_locked |
|
{ |
|
_is_locked = is_locked; |
|
|
|
if (_productionType == TFProductionTypeComic) { |
|
self.lockView.hidden = !_is_locked; |
|
} else { |
|
self.lockView.hidden = YES; |
|
} |
|
} |
|
|
|
- (void)setProductionType:(TFProductionType)productionType |
|
{ |
|
_productionType = productionType; |
|
|
|
if (productionType == TFProductionTypeAudio) { |
|
self.connerView.hidden = NO; |
|
} else { |
|
self.connerView.hidden = YES; |
|
} |
|
} |
|
|
|
- (void)setCoverDirection:(TFProductionCoverDirection)coverDirection |
|
{ |
|
_coverDirection = coverDirection; |
|
|
|
[self resetDefaultHoldImage]; |
|
} |
|
|
|
- (void)setCoverImageUrl:(NSString *)coverImageUrl |
|
{ |
|
_coverImageUrl = coverImageUrl; |
|
|
|
[self.productionView setImageWithURL:[NSURL URLWithString:coverImageUrl ? : @""] placeholder:HoldImage]; |
|
} |
|
|
|
- (void)setCoverTitleString:(NSString *)coverTitleString |
|
{ |
|
_coverTitleString = coverTitleString; |
|
|
|
if (coverTitleString.length > 0) { |
|
self.bottomTitleView.hidden = NO; |
|
|
|
self.bottomTitleLabel.hidden = NO; |
|
self.bottomTitleLabel.text = coverTitleString; |
|
} |
|
} |
|
|
|
@end
|
|
|