123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- //
- // YOUPAIZYDynamicVideoCell.m
- // VQU
- //
- // Created by Elaine on 2020/11/17.
- // Copyright © 2020 leo. All rights reserved.
- //
- #import "YOUPAIZYDynamicVideoCell.h"
- @interface YOUPAIZYDynamicVideoCell()
- //@property(nonatomic,strong)UILabel *likeCountL;
- //@property(nonatomic,strong)UILabel *giltCountL;
- @property (nonatomic,weak) UIButton *youpaiplikeBtn;
- @property (nonatomic,weak) UILabel *youpaiptitleL;
- @end
- @implementation YOUPAIZYDynamicVideoCell
- -(instancetype)initWithFrame:(CGRect)frame
- {
- self = [super initWithFrame:frame];
- if (self){
- [self youpaifinitUI];
- }
- return self;
- }
- - (void)youpaifinitUI{
- self.layer.cornerRadius = 5.0f;
- self.layer.masksToBounds = YES;
- self.backgroundColor = [UIColor clearColor];
- self.youpaipcoverImgV = [[UIImageView alloc]initWithFrame:self.contentView.bounds];
- self.youpaipcoverImgV.contentMode = UIViewContentModeScaleAspectFill;
- self.youpaipcoverImgV.layer.masksToBounds = YES;
- self.youpaipcoverImgV.layer.cornerRadius = 5.0f;
- [self.contentView addSubview:self.youpaipcoverImgV];
-
- UIView *bottomBkgView = [[UIView alloc]initWithFrame:CGRectMake(0, self.frame.size.height-45.0f, self.frame.size.width, 45.0f)];
- CAGradientLayer *gradientLayerBot = [CAGradientLayer layer];
- gradientLayerBot.frame = bottomBkgView.bounds;
- //设置渐变颜色数组,可以加透明度的渐变
- gradientLayerBot.colors = @[(__bridge id)HexColorFromRGBA(0x000000, 0.001).CGColor,(__bridge id)HexColorFromRGBA(0x000000, 0.3).CGColor];
- //设置渐变区域的起始和终止位置(范围为0-1)
- gradientLayerBot.startPoint = CGPointMake(0, 0);
- gradientLayerBot.endPoint = CGPointMake(0, 1);
- [bottomBkgView.layer addSublayer:gradientLayerBot];
- [self.contentView addSubview:bottomBkgView];
-
- UIImageView *playImgV = [[UIImageView alloc] init];
- playImgV.image = [UIImage imageNamed:@"vqu_images_ic_p_vqu_images_D_video_play"];
- [self.contentView addSubview:playImgV];
- [playImgV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.center.equalTo(self.contentView);
- make.size.mas_offset(CGSizeMake(34.0f, 34.0f));
- }];
-
- UIButton *likeBtn = [[UIButton alloc]init];
- likeBtn.titleLabel.font = LCFont(10);
- [likeBtn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
- [likeBtn setImage:[UIImage imageNamed:@"vqu_images_ic_p_video_like_select"] forState:UIControlStateSelected];
- [likeBtn setImage:[UIImage imageNamed:@"vqu_images_ic_p_video_like_normal"] forState:UIControlStateNormal];
- [likeBtn addTarget:self action:@selector(youpaiflikeClick) forControlEvents:(UIControlEventTouchUpInside)];
- [bottomBkgView addSubview:likeBtn];
- self.youpaiplikeBtn = likeBtn;
- [likeBtn makeConstraints:^(MASConstraintMaker *make) {
- make.left.offset(8.0f);
- make.top.offset(0);
- make.height.equalTo(25.0f);
- }];
-
- UILabel *titleL = [[UILabel alloc]init];
- titleL.textColor = HexColorFromRGB(0xFFFFFF);
- titleL.textAlignment = NSTextAlignmentLeft;
- titleL.font = LCFont(12);
- [bottomBkgView addSubview:titleL];
- self.youpaiptitleL = titleL;
- [titleL mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.offset(8.0f);
- make.right.offset(-8.0f);
- make.top.equalTo(likeBtn.mas_bottom).offset(0.0f);
- }];
- }
- -(void)setYoupaipmodel:(YOUPAIZYVideoModel *)model{
- _youpaipmodel = model;
- [self.youpaipcoverImgV sd_setImageWithURL:[NSURL URLWithString:model.youpaipcover_url]];
- [self.youpaiplikeBtn setTitle:[NSString stringWithFormat:@"%zd",model.youpaiplike_count] forState:(UIControlStateNormal)];
- if (model.youpaipis_like) {
- self.youpaiplikeBtn.selected = YES;
- }else{
- self.youpaiplikeBtn.selected = NO;
- }
- self.youpaiptitleL.text= model.youpaipcontent;
- }
- - (void)youpaiflikeClick{
- [LCHttpHelper requestWithURLString:TrendsLike parameters:@{@"vt_id":self.youpaipmodel.youpaipvideoId} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code==0) {//成功
- NSInteger type = [[[dict objectForKey:@"data"] objectForKey:@"type"] integerValue];
- NSString *like_count = [NSString stringWithFormat:@"%@",[[dict objectForKey:@"data"] objectForKey:@"like_count"]];
- self.youpaipmodel.youpaiplike_count = [like_count integerValue];
- self.youpaipmodel.youpaipis_like = type;
-
- [self.youpaiplikeBtn setTitle:[NSString stringWithFormat:@"%zd",self.youpaipmodel.youpaiplike_count] forState:(UIControlStateNormal)];
- if (self.youpaipmodel.youpaipis_like) {
- self.youpaiplikeBtn.selected = YES;
- }else{
- self.youpaiplikeBtn.selected = NO;
- }
- }
- } failure:^(NSError *error) {
-
- }];
- }
- @end
|