123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- //
- // FKBookRecSingleView.m
- // FirstLink
- //
- // Created by jack on 16/4/28.
- // Copyright © 2016年 FirstLink. All rights reserved.
- //
- #import "FKBookRecSingleView.h"
- @implementation FKBookRecSingleView
- - (instancetype)initWithFrame:(CGRect)frame{
- if (self = [super initWithFrame:frame]) {
- [self addAllSubviews];
- [self addTapGesture];
- }
- return self;
- }
- - (void)addAllSubviews{
-
- self.backgroundColor = UIColorFromRGB(0xdbdbdb);
- [self addSubview:self.imageView];
- [self addSubview:self.priceLabel];
-
- [self.imageView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.left.right.equalTo(self);
- make.height.equalTo(self.mas_width);
- }];
-
- [self.priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.bottom.equalTo(self);
- make.height.mas_equalTo(20);
- make.right.equalTo(self).offset(- 10);
- }];
- }
- - (void)addTapGesture{
- UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(singleTap)];
- [self addGestureRecognizer:tap];
- }
- - (void)fk_configWithModel:(FKBookRecProItem *)item{
- if ([item isKindOfClass:[FKBookRecProItem class]]){
- [self.imageView setImageWithURL:item.picUrl cdnWidth:100.0f];
- self.priceLabel.text = [NSString stringWithFormat:@"¥%@", [FLStringHelper convertFenToYuan:item.currentPrice]];
- self.productId = item.itemID;
- }
- }
- - (void)singleTap{
- if (self.clickAction){
- WeakSelf(weakSelf);
- self.clickAction(weakSelf);
- }
- }
- - (UIImageView *)imageView{
- if (_imageView == nil) {
- _imageView = [[UIImageView alloc]init];
- _imageView.contentMode = UIViewContentModeScaleAspectFit;
- _imageView.backgroundColor = [UIColor whiteColor];
- }
- return _imageView;
- }
- - (UILabel *)priceLabel{
- if (_priceLabel == nil) {
- _priceLabel = [[UILabel alloc]init];
- _priceLabel.textColor = UIColorFromRGB(0x333333);
- _priceLabel.font = [UIFont systemFontOfSize:12];
- _priceLabel.textAlignment = NSTextAlignmentRight;
- _priceLabel.lineBreakMode = NSLineBreakByTruncatingTail;
- }
- return _priceLabel;
- }
- @end
|