123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- //
- // YOUPAIWZHorizontalPageCell.m
- // WZShenmaStar
- //
- // Created by bigbiao on 2017/5/10.
- // Copyright © 2017年 BigBiao. All rights reserved.
- //
- #import "YOUPAIWZHorizontalPageCell.h"
- @implementation YOUPAIWZHorizontalPageCell
- -(instancetype)initWithFrame:(CGRect)frame{
- self = [super initWithFrame:frame];
- if (self) {
-
- self.youpaipbgV = [[UIView alloc] init];
- [self.contentView addSubview:self.youpaipbgV];
-
- [self.youpaipbgV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.offset(0.0f);
- make.bottom.offset(0.0f);
- make.left.offset(6.5f);
- make.right.offset(-6.5f);
- }];
-
- CGFloat width = 51.0f;
- self.youpaipimgView = [[UIImageView alloc] init];
- self.youpaipimgView.contentMode = UIViewContentModeScaleAspectFit;
- [self.youpaipbgV addSubview:self.youpaipimgView];
- [self.youpaipimgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerX.equalTo(self);
- make.top.offset(2.0f);
- make.size.mas_offset(CGSizeMake(width, width));
- }];
-
-
- self.youpaiptitleL = [[UILabel alloc] init];
- self.youpaiptitleL.font = [UIFont systemFontOfSize:12];
- self.youpaiptitleL.textColor = LZ475A7DColor;
- self.youpaiptitleL.textAlignment = NSTextAlignmentCenter;
- [self.youpaipbgV addSubview:self.youpaiptitleL];
- [self.youpaiptitleL mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.offset(0.0f);
- make.right.offset(0.0f);
- make.top.equalTo(self.youpaipimgView.mas_bottom);
- make.height.offset(15.0f);
- }];
-
- self.youpaippriceL = [[UILabel alloc]init];
- self.youpaippriceL.font = [UIFont systemFontOfSize:10];
- self.youpaippriceL.textColor = LZA3AABEColor;
- self.youpaippriceL.textAlignment = NSTextAlignmentCenter;
- [self.youpaipbgV addSubview:self.youpaippriceL];
- [self.youpaippriceL mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerX.equalTo(self.mas_centerX).offset(6.0f);
- make.top.equalTo(self.youpaiptitleL.mas_bottom).offset(3);
- }];
- UIImageView *coinImgV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"vqu_images_ic_user_show_zuanshi"]];
- coinImgV.contentMode = UIViewContentModeScaleAspectFit;
- [self.youpaipbgV addSubview:coinImgV];
- [coinImgV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.equalTo(self.youpaippriceL.mas_left).offset(-3.0f);
- make.centerY.equalTo(self.youpaippriceL);
- make.size.mas_offset(CGSizeMake(10, 9));
- }];
- //角标
- self.youpaipbageBtn = [UIButton new];
- [self.youpaipbgV addSubview:self.youpaipbageBtn];
- [self.youpaipbageBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.mas_equalTo(0);
- make.top.mas_equalTo(0);
- make.size.mas_equalTo(CGSizeMake(36, 16));
- }];
- [self.youpaipbageBtn setTitle:@"活动" forState:UIControlStateNormal];
- [self.youpaipbageBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
- self.youpaipbageBtn.titleLabel.font = [UIFont systemFontOfSize:9];
- //self.youpaipbageBtn.layer.cornerRadius = 2.0f;
- //self.youpaipbageBtn.layer.masksToBounds = YES;
- //self.youpaipbageBtn.backgroundColor = UIColor.clearColor;
- self.youpaipbageBtn.hidden = YES;
- [self.youpaipbageBtn ym_setGradientBackgroundWithColors:kMainGradColors locations:kMainGradLocation startPoint:kMainGradStartP endPoint:kMainGradEndP];
- UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, 36, 16) byRoundingCorners:UIRectCornerTopLeft | UIRectCornerBottomRight cornerRadii:CGSizeMake(16, 0)];
- CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
- maskLayer.frame = CGRectMake(0, 0, 36, 16);
- maskLayer.path = maskPath.CGPath;
- self.youpaipbageBtn.layer.mask = maskLayer;
- self.youpaipbageBtn.layer.masksToBounds = YES;
-
- //个数
-
- self.youpaipcountLabel = [[UILabel alloc]init];
- self.youpaipcountLabel.font = [UIFont systemFontOfSize:9];
- self.youpaipcountLabel.textColor = LZ7C69FEColor;
- [self.youpaipbgV addSubview:self.youpaipcountLabel];
- [self.youpaipcountLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(2);
- make.top.mas_equalTo(2);
- make.height.offset(15);
- // make.size.mas_equalTo(CGSizeMake(40, 15));
- }];
- self.youpaipbageBtn.layer.zPosition = MAXFLOAT;
-
- }
- return self;
- }
- -(void)setYoupaipmodel:(YOUPAILCGiftModel *)model{
- _youpaipmodel = model;
- // self.imgView.image = [LCTools giftImgWithGiftUrlStr:model.img];
- //modify by leo 解决主线程卡死问题 20191204
- NSString* urlStr = [NSString stringWithFormat:@"%@/%@",[LCSaveData getImageUrl]?[LCSaveData getImageUrl]:BaseImgUrl,model.youpaipimg];
- [self.youpaipimgView sd_setImageWithURL:[NSURL URLWithString:urlStr]];
- // self.titleL.text = self.model.name;
- // self.priceL.text = [NSString stringWithFormat:@"%zd",self.model.price];
- if (model.youpaipnum>0) {
- self.youpaipcountLabel.text = [NSString stringWithFormat:@"×%ld",(long)model.youpaipnum];
- }
- NSString *signStr =[NSString stringWithFormat:@"%@",model.youpaipsign];
- if (signStr.length>0) {
- self.youpaipbageBtn.hidden = NO;
- [self.youpaipbageBtn setTitle:model.youpaipsign forState:UIControlStateNormal];
- NSLog(@"签名是:%@",model.youpaipsign);
- }else{
- self.youpaipbageBtn.hidden = YES;
- }
- self.youpaiptitleL.text = self.youpaipmodel.youpaipname;
- self.youpaippriceL.text = [NSString stringWithFormat:@"%zd",self.youpaipmodel.youpaipprice];
- if (model.youpaipselected) {
- self.youpaipbgV.layer.borderColor = HexColorFromRGB(0xEC54BD).CGColor;
- self.youpaipbgV.layer.borderWidth = 2.0;
- self.youpaipbgV.layer.cornerRadius = 8;
- }else{
- self.youpaipbgV.layer.borderColor = [UIColor clearColor].CGColor;
- self.youpaipbgV.layer.borderWidth = 0;
- self.youpaipbgV.layer.cornerRadius = 0;
- }
- }
- @end
|