ifish/Ifish/controllers/IfishTabControllers/设备/IfishDeviceSelectList/IfishMainInfoCell.m

176 lines
5.6 KiB
Objective-C

//
// IfishMainInfoCell.m
// Ifish
//
// Created by wbzhan on 2019/8/23.
// Copyright © 2019 lianlian. All rights reserved.
//
#import "IfishMainInfoCell.h"
@interface IfishMainInfoCell()
Strong UIImageView *iconImage;
Strong UILabel *titleLabel;
Strong UILabel *subTitle;
Strong UIImageView *watchImage;//查看数
Strong UILabel *watchLabel;
Strong UIImageView *favImage;//收藏数
Strong UILabel *favLabel;
Strong UIView *sepLine;
@end
@implementation IfishMainInfoCell
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
[self.contentView addSubview:self.sepLine];
[self.contentView addSubview:self.iconImage];
[self.contentView addSubview:self.titleLabel];
[self.contentView addSubview:self.subTitle];
[self.contentView addSubview:self.watchImage];
[self.contentView addSubview:self.watchLabel];
[self.contentView addSubview:self.favImage];
[self.contentView addSubview:self.favLabel];
[self.contentView addSubview:self.sepLine];
}
return self;
}
- (UIView *)sepLine{
if (!_sepLine) {
_sepLine = InitObject(UIView);
_sepLine.backgroundColor = RGB(222, 222, 222);
}
return _sepLine;
}
-(UIImageView *)iconImage{
if (!_iconImage) {
_iconImage = InitObject(UIImageView);
_iconImage.contentMode = UIViewContentModeScaleAspectFill;
_iconImage.clipsToBounds = YES;
}
return _iconImage;
}
-(UILabel *)titleLabel{
if (!_titleLabel) {
_titleLabel= InitObject(UILabel);
_titleLabel.font = FontSize(15);
_titleLabel.textColor=RGB(51, 51, 51);
}
return _titleLabel;
}
-(UIImageView *)watchImage{
if (!_watchImage) {
_watchImage = InitObject(UIImageView);
[_watchImage setImage:IMAGEBYENAME(@"icons_watch")];
}
return _watchImage;
}
-(UILabel *)watchLabel{
if (!_watchLabel) {
_watchLabel= InitObject(UILabel);
_watchLabel.font = FontSize(11);
_watchLabel.textColor=RGB(153, 153, 153);
_watchLabel.textAlignment = NSTextAlignmentCenter;
}
return _watchLabel;
}
-(UIImageView *)favImage{
if (!_favImage) {
_favImage = InitObject(UIImageView);
[_favImage setImage:IMAGEBYENAME(@"icons_fav")];
}
return _favImage;
}
-(UILabel *)favLabel{
if (!_favLabel) {
_favLabel= InitObject(UILabel);
_favLabel.font = FontSize(11);
_favLabel.textColor=RGB(153, 153, 153);
_favLabel.textAlignment = NSTextAlignmentCenter;
}
return _favLabel;
}
-(void)loadLayout{
[self.sepLine mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.top.width.mas_equalTo(self.contentView);
make.height.mas_equalTo(ONE_PIXEL_SIZE);
}];
[self.iconImage mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(15);
make.height.mas_equalTo(75);
make.left.mas_equalTo(23);
make.width.mas_equalTo(89);
}];
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.iconImage.mas_right).offset(9);
make.top.mas_equalTo(self.iconImage);
make.right.mas_equalTo(15);
}];
[self.watchImage mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(self.mas_bottom);
make.right.mas_equalTo(self.favImage.mas_left).offset(-kSizeFrom750(30));
make.width.mas_equalTo(kSizeFrom750(24));
make.height.mas_equalTo(kSizeFrom750(14));
}];
[self.watchLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.mas_equalTo(self.watchImage.mas_centerY);
make.height.mas_equalTo(kSizeFrom750(14));
make.left.mas_equalTo(self.watchImage.mas_centerX);
make.width.mas_greaterThanOrEqualTo(kSizeFrom750(14));
}];
[self.favImage mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(self.watchImage);
make.width.mas_equalTo(kSizeFrom750(22));
make.height.mas_equalTo(kSizeFrom750(20));
make.right.mas_equalTo(-kSizeFrom750(35));
}];
[self.favLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.height.mas_equalTo(self.watchLabel);
make.left.mas_equalTo(self.favImage.mas_centerX);
make.width.mas_greaterThanOrEqualTo(kSizeFrom750(14));
}];
}
//
//-(void)loadInfoWithModel:(GoodsModel *)model{
//
// NSString *soldTxt = [NSString stringWithFormat:@"已销售%@件",model.sales_num];
//
// NSMutableAttributedString *priceAttr = [CommonUtils diffierentFontWithString:soldTxt rang:[soldTxt rangeOfString:model.sales_num] font:self.soldLabel.font color:Color_Pink spacingBeforeValue:0 lineSpace:0];
// [self.soldLabel setAttributedText:priceAttr];
// if ([model.collection_num integerValue]>1000) {
// model.collection_num = @"999+";
// }
// if ([model.click integerValue]>1000) {
// model.click = @"999+";
// }
// self.favLabel.text = [NSString stringWithFormat:@" %@ ",model.collection_num];
// self.watchLabel.text = [NSString stringWithFormat:@" %@ ",model.click];
// self.titleLabel.text = model.title;
// [self.iconImage setImageWithString:model.img_url];
//}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end