| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173 |
- //
- // BGVideoMirrorCell.m
- // BuguLive
- //
- // Created by fanwe2014 on 2017/3/24.
- // Copyright © 2017年 xfg. All rights reserved.
- //
- #import "BGVideoMirrorCell.h"
- #import "TTTAttributedLabel.h"
- @implementation BGVideoMirrorCell
- - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
- {
- if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
- {
- self.contentView.bounds = [UIScreen mainScreen].bounds;
-
- [self creatMainView];
- }
- return self ;
- }
- - (void)creatMainView
- {
- self.headImgView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 40, 40)];
- self.headImgView.userInteractionEnabled = YES;
- self.headImgView.layer.cornerRadius = 20;
- self.headImgView.layer.masksToBounds = YES;
- self.headImgView.image = kDefaultPreloadHeadImg;
- self.headImgView.contentMode = UIViewContentModeScaleAspectFit;
- self.headImgView.tag = 2;
- UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(imgViewTap:)];
- [self.headImgView addGestureRecognizer:tap];
- [self addSubview:self.headImgView];
-
- self.iconImgView = [[UIImageView alloc] initWithFrame:CGRectMake(40, 40, 10, 10)];
- [self addSubview:self.iconImgView];
-
- self.zanLabel = [[UILabel alloc]initWithFrame:CGRectMake(kScreenW-50, 10, 40, 20)];
- self.zanLabel.textColor = kAppGrayColor3;
- self.zanLabel.font = [UIFont systemFontOfSize:11];
- [self addSubview:self.zanLabel];
-
- self.zanImgView = [[UIImageView alloc]initWithFrame:CGRectMake(kScreenW-64, 14, 12, 11)];
- self.zanImgView.image = [UIImage imageNamed:@"fw_personCenter_noZan"];
- [self addSubview:self.zanImgView];
-
- self.ZanBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- self.ZanBtn.frame =CGRectMake(kScreenW-65, 10, 65, 22);
- self.ZanBtn.backgroundColor = kClearColor;
- [self.ZanBtn addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];
- [self addSubview:self.ZanBtn];
-
- self.videoLabel = [[UILabel alloc]initWithFrame:CGRectMake(kScreenW-108, 10, 40, 20)];
- self.videoLabel.textColor = RGB(153, 153, 153);
- self.videoLabel.font = [UIFont systemFontOfSize:11];
- [self addSubview:self.videoLabel];
-
- self.videoImgView = [[UIImageView alloc]initWithFrame:CGRectMake(kScreenW-122, 14, 12, 11)];
- self.videoImgView.image = [UIImage imageNamed:@"fw_personCenter_playNum"];
- [self addSubview:self.videoImgView];
-
- self.videoBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- self.videoBtn.frame =CGRectMake(kScreenW-116, 10, 65, 22);
- self.videoBtn.tag = 1;
- self.videoBtn.backgroundColor = kClearColor;
- [self.videoBtn addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];
- [self addSubview:self.videoBtn];
-
- self.nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(60, 10, kScreenW-185, 20)];
- self.nameLabel.textColor = kAppGrayColor1;
- self.nameLabel.font = [UIFont systemFontOfSize:14];
- self.nameLabel.lineBreakMode = NSLineBreakByTruncatingTail;
- [self addSubview:self.nameLabel];
-
-
- self.abstractLabel = [[TTTAttributedLabel alloc]initWithFrame:CGRectMake(70,CGRectGetMaxY(self.nameLabel.frame)+5, kScreenW-70, 0)];
- self.abstractLabel.textColor = RGB(153, 153, 153);
- self.abstractLabel.textAlignment = NSTextAlignmentLeft;
- self.abstractLabel.font = [UIFont systemFontOfSize:11];
- self.abstractLabel.numberOfLines = 0;
- [self addSubview:self.abstractLabel];
-
- self.lineView = [[UIView alloc]init];
- self.lineView.backgroundColor = kAppSpaceColor2;
- [self addSubview:self.lineView];
-
-
- }
- - (CGFloat)creatCellWithModel:(PersonCenterListModel *)model andRow:(int)row isVideo:(BOOL)isVideo
- {
- [self.headImgView sd_setImageWithURL:[NSURL URLWithString:model.head_image] placeholderImage:kDefaultPreloadHeadImg];
- self.headImgView.tag = row;
- if ([model.is_authentication intValue] != 2)
- {
- self.iconImgView.hidden = YES;
- }
- [self.iconImgView sd_setImageWithURL:[NSURL URLWithString:model.v_icon] placeholderImage:kDefaultPreloadHeadImg];
- NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] initWithString:model.nick_name];
- self.nameLabel.attributedText = attr;
-
- NSString *nameString;
- if (isVideo)
- {
- nameString = [NSString stringWithFormat:ASLocalizedString(@"视频简介:%@"),model.content];
-
- }else
- {
- self.videoLabel.hidden = YES;
- self.videoBtn.hidden = YES;
- self.videoImgView.hidden = YES;
- nameString = [NSString stringWithFormat:ASLocalizedString(@"写真简介:%@"),model.content];
- }
-
- if (model.has_digg ==1)
- {
- self.zanImgView.image = [UIImage imageNamed:@"fw_personCenter_zan"];
- self.zanLabel.textColor = kAppGrayColor1;
- }
-
- self.zanLabel.text = model.digg_count;
- self.videoLabel.text = model.video_count;
-
- NSMutableAttributedString *attr1 = [[NSMutableAttributedString alloc] initWithString:nameString];
- self.abstractLabel.attributedText = attr1;
-
- NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc]init];
- paragraphStyle.maximumLineHeight = 18.0f;
- paragraphStyle.minimumLineHeight = 16.0f;
- paragraphStyle.firstLineHeadIndent = 0.0f;
- paragraphStyle.lineSpacing = 6.0f;
- paragraphStyle.firstLineHeadIndent = 0.0f;
- paragraphStyle.headIndent = 0.0f;
- paragraphStyle.alignment = NSTextAlignmentLeft;
-
- UIFont *font = [UIFont systemFontOfSize:11];
- NSDictionary *attributes = @{NSFontAttributeName:font, NSParagraphStyleAttributeName:paragraphStyle,NSForegroundColorAttributeName:RGB(153, 153, 153)};
- self.abstractLabel.attributedText = [[NSAttributedString alloc]initWithString:nameString attributes:attributes];
- CGSize size = CGSizeMake(self.abstractLabel.frame.size.width, 1000.0f);
- CGFloat height = [self.abstractLabel sizeThatFits:size].height;
- self.abstractLabel.verticalAlignment = TTTAttributedLabelVerticalAlignmentTop;
-
- if (height < 21)
- {
- height = 21;
- }
- self.abstractLabel.frame = CGRectMake(60, CGRectGetMaxY(self.nameLabel.frame)+5, kScreenW-70, height);
- self.lineView.frame = CGRectMake(10, CGRectGetMaxY(self.abstractLabel.frame)+12, kScreenW-10, 1);
- return self.lineView.frame.size.height+self.lineView.frame.origin.y;
- }
- - (void)buttonClick:(UIButton *)sender
- {
- if (self.ZVDelegate && [self.ZVDelegate respondsToSelector:@selector(zanOrVideoClickWithTag:)])
- {
- [self.ZVDelegate zanOrVideoClickWithTag:(int)sender.tag];
- }
- }
- - (void)imgViewTap:(UITapGestureRecognizer *)tap
- {
- if (self.ZVDelegate && [self.ZVDelegate respondsToSelector:@selector(zanOrVideoClickWithTag:)])
- {
- [self.ZVDelegate zanOrVideoClickWithTag:2];
- }
- }
- @end
|