YOUPAIWZHorizontalPageCell.m 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. //
  2. // YOUPAIWZHorizontalPageCell.m
  3. // WZShenmaStar
  4. //
  5. // Created by bigbiao on 2017/5/10.
  6. // Copyright © 2017年 BigBiao. All rights reserved.
  7. //
  8. #import "YOUPAIWZHorizontalPageCell.h"
  9. @implementation YOUPAIWZHorizontalPageCell
  10. -(instancetype)initWithFrame:(CGRect)frame{
  11. self = [super initWithFrame:frame];
  12. if (self) {
  13. self.youpaipbgV = [[UIView alloc] init];
  14. [self.contentView addSubview:self.youpaipbgV];
  15. [self.youpaipbgV mas_makeConstraints:^(MASConstraintMaker *make) {
  16. make.top.offset(0.0f);
  17. make.bottom.offset(0.0f);
  18. make.left.offset(6.5f);
  19. make.right.offset(-6.5f);
  20. }];
  21. CGFloat width = 51.0f;
  22. self.youpaipimgView = [[UIImageView alloc] init];
  23. self.youpaipimgView.contentMode = UIViewContentModeScaleAspectFit;
  24. [self.youpaipbgV addSubview:self.youpaipimgView];
  25. [self.youpaipimgView mas_makeConstraints:^(MASConstraintMaker *make) {
  26. make.centerX.equalTo(self);
  27. make.top.offset(2.0f);
  28. make.size.mas_offset(CGSizeMake(width, width));
  29. }];
  30. self.youpaiptitleL = [[UILabel alloc] init];
  31. self.youpaiptitleL.font = [UIFont systemFontOfSize:12];
  32. self.youpaiptitleL.textColor = LZ475A7DColor;
  33. self.youpaiptitleL.textAlignment = NSTextAlignmentCenter;
  34. [self.youpaipbgV addSubview:self.youpaiptitleL];
  35. [self.youpaiptitleL mas_makeConstraints:^(MASConstraintMaker *make) {
  36. make.left.offset(0.0f);
  37. make.right.offset(0.0f);
  38. make.top.equalTo(self.youpaipimgView.mas_bottom);
  39. make.height.offset(15.0f);
  40. }];
  41. self.youpaippriceL = [[UILabel alloc]init];
  42. self.youpaippriceL.font = [UIFont systemFontOfSize:10];
  43. self.youpaippriceL.textColor = LZA3AABEColor;
  44. self.youpaippriceL.textAlignment = NSTextAlignmentCenter;
  45. [self.youpaipbgV addSubview:self.youpaippriceL];
  46. [self.youpaippriceL mas_makeConstraints:^(MASConstraintMaker *make) {
  47. make.centerX.equalTo(self.mas_centerX).offset(6.0f);
  48. make.top.equalTo(self.youpaiptitleL.mas_bottom).offset(3);
  49. }];
  50. UIImageView *coinImgV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"vqu_images_ic_user_show_zuanshi"]];
  51. coinImgV.contentMode = UIViewContentModeScaleAspectFit;
  52. [self.youpaipbgV addSubview:coinImgV];
  53. [coinImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  54. make.right.equalTo(self.youpaippriceL.mas_left).offset(-3.0f);
  55. make.centerY.equalTo(self.youpaippriceL);
  56. make.size.mas_offset(CGSizeMake(10, 9));
  57. }];
  58. //角标
  59. self.youpaipbageBtn = [UIButton new];
  60. [self.youpaipbgV addSubview:self.youpaipbageBtn];
  61. [self.youpaipbageBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  62. make.right.mas_equalTo(0);
  63. make.top.mas_equalTo(0);
  64. make.size.mas_equalTo(CGSizeMake(36, 16));
  65. }];
  66. [self.youpaipbageBtn setTitle:@"活动" forState:UIControlStateNormal];
  67. [self.youpaipbageBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  68. self.youpaipbageBtn.titleLabel.font = [UIFont systemFontOfSize:9];
  69. //self.youpaipbageBtn.layer.cornerRadius = 2.0f;
  70. //self.youpaipbageBtn.layer.masksToBounds = YES;
  71. //self.youpaipbageBtn.backgroundColor = UIColor.clearColor;
  72. self.youpaipbageBtn.hidden = YES;
  73. [self.youpaipbageBtn ym_setGradientBackgroundWithColors:kMainGradColors locations:kMainGradLocation startPoint:kMainGradStartP endPoint:kMainGradEndP];
  74. UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, 36, 16) byRoundingCorners:UIRectCornerTopLeft | UIRectCornerBottomRight cornerRadii:CGSizeMake(16, 0)];
  75. CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
  76. maskLayer.frame = CGRectMake(0, 0, 36, 16);
  77. maskLayer.path = maskPath.CGPath;
  78. self.youpaipbageBtn.layer.mask = maskLayer;
  79. self.youpaipbageBtn.layer.masksToBounds = YES;
  80. //个数
  81. self.youpaipcountLabel = [[UILabel alloc]init];
  82. self.youpaipcountLabel.font = [UIFont systemFontOfSize:9];
  83. self.youpaipcountLabel.textColor = LZ7C69FEColor;
  84. [self.youpaipbgV addSubview:self.youpaipcountLabel];
  85. [self.youpaipcountLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  86. make.left.mas_equalTo(2);
  87. make.top.mas_equalTo(2);
  88. make.height.offset(15);
  89. // make.size.mas_equalTo(CGSizeMake(40, 15));
  90. }];
  91. self.youpaipbageBtn.layer.zPosition = MAXFLOAT;
  92. }
  93. return self;
  94. }
  95. -(void)setYoupaipmodel:(YOUPAILCGiftModel *)model{
  96. _youpaipmodel = model;
  97. // self.imgView.image = [LCTools giftImgWithGiftUrlStr:model.img];
  98. //modify by leo 解决主线程卡死问题 20191204
  99. NSString* urlStr = [NSString stringWithFormat:@"%@/%@",[LCSaveData getImageUrl]?[LCSaveData getImageUrl]:BaseImgUrl,model.youpaipimg];
  100. [self.youpaipimgView sd_setImageWithURL:[NSURL URLWithString:urlStr]];
  101. // self.titleL.text = self.model.name;
  102. // self.priceL.text = [NSString stringWithFormat:@"%zd",self.model.price];
  103. if (model.youpaipnum>0) {
  104. self.youpaipcountLabel.text = [NSString stringWithFormat:@"×%ld",(long)model.youpaipnum];
  105. }
  106. NSString *signStr =[NSString stringWithFormat:@"%@",model.youpaipsign];
  107. if (signStr.length>0) {
  108. self.youpaipbageBtn.hidden = NO;
  109. [self.youpaipbageBtn setTitle:model.youpaipsign forState:UIControlStateNormal];
  110. NSLog(@"签名是:%@",model.youpaipsign);
  111. }else{
  112. self.youpaipbageBtn.hidden = YES;
  113. }
  114. self.youpaiptitleL.text = self.youpaipmodel.youpaipname;
  115. self.youpaippriceL.text = [NSString stringWithFormat:@"%zd",self.youpaipmodel.youpaipprice];
  116. if (model.youpaipselected) {
  117. self.youpaipbgV.layer.borderColor = HexColorFromRGB(0xEC54BD).CGColor;
  118. self.youpaipbgV.layer.borderWidth = 2.0;
  119. self.youpaipbgV.layer.cornerRadius = 8;
  120. }else{
  121. self.youpaipbgV.layer.borderColor = [UIColor clearColor].CGColor;
  122. self.youpaipbgV.layer.borderWidth = 0;
  123. self.youpaipbgV.layer.cornerRadius = 0;
  124. }
  125. }
  126. @end