//
|
// SearchDetailListCell.m
|
// BuWanVideo2.0
|
//
|
// Created by Aeline on 2020/9/19.
|
// Copyright © 2020 com.yeshi.buwansheque.ios. All rights reserved.
|
//
|
|
#import "SearchDetailListCell.h"
|
#import "UIImageView+YTH.h"
|
|
@interface SearchDetailListCell ()
|
|
@property (nonatomic, nullable, strong) UIImageView *imageViewLogo;
|
|
@property (nonatomic, nullable, strong) UILabel *labelTitle;
|
@property (nonatomic, nullable, strong) UILabel *labelTag;
|
@property (nonatomic, nullable, strong) UILabel *labelZY;
|
|
@property (nonatomic, nullable, strong) UIButton *buttonPlay;
|
|
@property (nonatomic, nullable, strong) UIView *viewLevel;
|
@end
|
|
@implementation SearchDetailListCell
|
|
- (void)awakeFromNib {
|
[super awakeFromNib];
|
// Initialization code
|
}
|
|
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
|
[super setSelected:selected animated:animated];
|
|
// Configure the view for the selected state
|
}
|
|
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
|
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
|
if (self) {
|
self.contentView.backgroundColor = [UIColor whiteColor];
|
self.selectionStyle = UITableViewCellSelectionStyleNone;//设置cell点击效果
|
[self setupViewConfig];
|
}
|
return self;
|
}
|
|
- (void)setupViewConfig {
|
[self.contentView addSubview:self.imageViewLogo];
|
[self.contentView addSubview:self.labelTitle];
|
[self.contentView addSubview:self.labelTag];
|
[self.contentView addSubview:self.labelZY];
|
[self.contentView addSubview:self.buttonPlay];
|
[self.contentView addSubview:self.viewLevel];
|
}
|
|
- (void)setModel:(XYRVideoInfoModel *)model {
|
_model = model;
|
if (model) {
|
[self.imageViewLogo setYthImageWithURL:model.Vpicture placeholderImage:nil];
|
self.labelTitle.text = model.Name;
|
self.labelTag.text = model.Tag;
|
self.labelZY.text = model.MainActor;
|
|
for (__strong UIView *view in [self.viewLevel subviews]) {
|
[view removeFromSuperview];
|
view = nil;
|
}
|
for (int i = 0; i < model.VideoDetailList.count; i++) {
|
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
[button setTitle:[NSString stringWithFormat:@"%@",model.VideoDetailList[i][@"Tag"]] forState:UIControlStateNormal];
|
if (model.VideoDetailList.count > 5) {
|
if (i == 2) {
|
[button setTitle:@"..." forState:UIControlStateNormal];
|
}
|
|
if (i == 3) {
|
[button setTitle:[NSString stringWithFormat:@"%@",model.VideoDetailList[[model.VideoDetailList count] - 2][@"Tag"]] forState:UIControlStateNormal];
|
}
|
|
if (i == 4) {
|
[button setTitle:[NSString stringWithFormat:@"%@",model.VideoDetailList[[model.VideoDetailList count] - 1][@"Tag"]] forState:UIControlStateNormal];
|
}
|
}
|
|
[button setTitleColor:UIColorFromRGBValue(0x000000) forState:UIControlStateNormal];
|
button.titleLabel.font = [UIFont systemFontOfSize:12];
|
button.backgroundColor = UIColorFromRGBValue(0xD3D3D3);
|
button.layer.masksToBounds = YES;
|
button.layer.cornerRadius = 5;
|
button.tag = i;
|
[self.viewLevel addSubview:button];
|
CGFloat width = (KScreenW - 60) / 5;
|
button.frame = CGRectMake(10 + 10 * i + width * i, 0, width, 29);
|
|
[button addTarget:self action:@selector(touchIndex:) forControlEvents:UIControlEventTouchUpInside];
|
}
|
}
|
}
|
|
- (void)touchIndex:(UIButton *)button {
|
if (_delegate && [_delegate respondsToSelector:@selector(playVideo:)]) {
|
[_delegate playVideo:_model];
|
}
|
}
|
|
- (UIImageView *)imageViewLogo {
|
if (!_imageViewLogo) {
|
_imageViewLogo = [[UIImageView alloc] initWithFrame:CGRectMake(9, 15, 95, 131)];
|
[_imageViewLogo setContentScaleFactor:[[UIScreen mainScreen] scale]];
|
_imageViewLogo.contentMode = UIViewContentModeScaleAspectFill;
|
_imageViewLogo.clipsToBounds = YES;
|
_imageViewLogo.backgroundColor = UIColorFromRGBValue(0xf4f4f4);
|
}
|
return _imageViewLogo;
|
}
|
|
- (UILabel *)labelTitle {
|
if (!_labelTitle) {
|
_labelTitle = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(self.imageViewLogo.frame) + 17, 16, KScreenW - 121, 15)];
|
_labelTitle.textColor = UIColorFromRGBValue(0x000000);
|
_labelTitle.textAlignment = NSTextAlignmentLeft;
|
_labelTitle.font = [UIFont systemFontOfSize:15];
|
}
|
return _labelTitle;
|
}
|
|
- (UILabel *)labelTag {
|
if (!_labelTag) {
|
_labelTag = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(self.imageViewLogo.frame) + 17, CGRectGetMaxY(self.labelTitle.frame) + 7, KScreenW - 131, 15)];
|
_labelTag.textColor = UIColorFromRGBValue(0xA3A3A3);
|
_labelTag.textAlignment = NSTextAlignmentLeft;
|
_labelTag.font = [UIFont systemFontOfSize:12];
|
}
|
return _labelTag;
|
}
|
|
- (UILabel *)labelZY {
|
if (!_labelZY) {
|
_labelZY = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(self.imageViewLogo.frame) + 17, CGRectGetMaxY(self.labelTag.frame) + 15, KScreenW - 131, 30)];
|
_labelZY.textColor = UIColorFromRGBValue(0xA3A3A3);
|
_labelZY.textAlignment = NSTextAlignmentLeft;
|
_labelZY.font = [UIFont systemFontOfSize:12];
|
_labelZY.lineBreakMode = NSLineBreakByTruncatingTail;
|
_labelZY.numberOfLines = 2;
|
}
|
return _labelZY;
|
}
|
|
- (UIButton *)buttonPlay {
|
if (!_buttonPlay) {
|
_buttonPlay = [UIButton buttonWithType:UIButtonTypeCustom];
|
_buttonPlay.frame = CGRectMake(CGRectGetMaxX(self.imageViewLogo.frame) + 17, CGRectGetMaxY(self.labelZY.frame) + 15, 109, 24);
|
[_buttonPlay setTitle:@"立即播放" forState:UIControlStateNormal];
|
[_buttonPlay setTitleColor:UIColorFromRGBValue(0xFFE84E) forState:UIControlStateNormal];
|
_buttonPlay.titleLabel.font = [UIFont systemFontOfSize:12];
|
_buttonPlay.backgroundColor = UIColorFromRGBValue(0x0051F5);
|
_buttonPlay.layer.masksToBounds = YES;
|
_buttonPlay.layer.cornerRadius = 12;
|
[_buttonPlay addTarget:self action:@selector(touchIndex:) forControlEvents:UIControlEventTouchUpInside];
|
}
|
return _buttonPlay;
|
}
|
|
- (UIView *)viewLevel {
|
if (!_viewLevel) {
|
_viewLevel = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(self.imageViewLogo.frame) + 8, KScreenW, 29)];
|
}
|
return _viewLevel;
|
}
|
|
- (CGSize)sizeWithText:(NSString *)text font:(UIFont *)font maxSize:(CGSize)maxSize {
|
NSDictionary *attrs = @{NSFontAttributeName:font};
|
return [text boundingRectWithSize:maxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:attrs context:nil].size;
|
}
|
|
@end
|