1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
//
// KWMNewHomeCell.m
// iCemarose
//
// Created by HouWeiBin on 2017/6/2.
// Copyright © 2017年 kollway. All rights reserved.
//
#import "KWMNewHomeCell.h"
#import "UIView+Prettify.h"
#import "KWMStringUtil.h"
#import "KWMImageUtil.h"
#import "UIImageView+WebCache.h"
#import "NSLayoutConstraint+Multiplier.h"
#import "UIColor+SAMAdditions.h"
@interface KWMNewHomeCell()
@property(nonatomic,weak) IBOutlet UILabel *lbBrand;
@property(nonatomic,weak) IBOutlet UILabel *lbName;
@property(nonatomic,weak) IBOutlet UILabel *lbPrice;
@property(nonatomic,weak) IBOutlet UIImageView *ivProduct;
@property(nonatomic,weak) IBOutlet UIView *vImageContentView;
@property(nonatomic,weak) IBOutlet NSLayoutConstraint *heightDetail;
@property(nonatomic,weak) IBOutlet NSLayoutConstraint *precentOfProductImageView;
@end
@implementation KWMNewHomeCell
- (void)awakeFromNib {
[super awakeFromNib];
[self.vContent initDefaultShadow];
}
-(void)setSingleShow:(BOOL)singleShow{
if(singleShow){
NSTextAlignment textAlignment = NSTextAlignmentCenter;
self.lbBrand.textAlignment = textAlignment;
self.lbName.textAlignment = textAlignment;
self.lbPrice.textAlignment = textAlignment;
self.lbName.numberOfLines = 1;
self.lbBrand.numberOfLines = 1;
// self.precentOfProductImageView = [self.precentOfProductImageView updateMultiplier:1];
// self.vImageContentView.backgroundColor = [UIColor sam_colorWithHex:@"F1929A"];
}
}
-(void)setProduct:(BUYProduct *)product{
_product = product;
if(product){
NSString *imageUrl = [KWMImageUtil getProductImageUrl:product ImageSize:SmallImage];
NSURL *imageURL = [NSURL URLWithString:imageUrl];
[self.ivProduct sd_setImageWithURL:imageURL placeholderImage:[UIImage imageNamed:@"ic_loading"]];
self.lbBrand.text = product.vendor;
self.lbName.text = product.title;
if(product.variantsArray.count>0){
BUYProductVariant *variant = product.variantsArray.firstObject;
self.lbPrice.text = [KWMStringUtil price:variant.price];
}
}
}
+(NSInteger)acturlHeight:(BUYProduct *)product width:(NSInteger)width{
NSInteger lbNameWidth = width - 60;
UIFont *font = [UIFont systemFontOfSize:9];
if(SYSTEM_VERSION_LESS_THAN(@"9.0")){
[UIFont fontWithName:@"PingFang SC" size:9];
}
NSInteger lbNameHeight = [KWMStringUtil getLabelHeight:product.title labelFont:font textWidth:lbNameWidth].height;
return width + 50 +lbNameHeight;
}
@end