| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- //
- // ServiceRecommendCell.m
- // jitao
- //
- // Created by 罗云飞 on 2017/12/21.
- // Copyright © 2017年 罗云飞. All rights reserved.
- //
- #import "ServiceRecommendCell.h"
- @implementation ServiceRecommendCell
- - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
-
- self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
- if (self) {
- UILabel *line = [UILabel new];
- line.backgroundColor = NewLineGrayColor;
- [self.contentView addSubview:line];
-
- line.sd_layout
- .leftEqualToView(self.contentView)
- .heightIs(10)
- .rightEqualToView(self.contentView)
- .topEqualToView(self.contentView);
- CGFloat proportion = (CGFloat)210/335;//图片宽高比
- _image = [UIImageView new];
- _image.backgroundColor = NewClearColor;
- ViewRadius(_image, 5);
- [self.contentView addSubview:_image];
-
- _image.sd_layout
- .leftSpaceToView(self.contentView, 15)
- .topSpaceToView(line, 15)
- .widthIs(SCREEN_WIDTH/2-20)
- .autoHeightRatio(proportion);
-
- _title = [UILabel new];
- _title.numberOfLines = 1;
- _title.lineBreakMode = NSLineBreakByTruncatingTail;
- _title.font = NewFont(fitScreenWidth(14));
- [self.contentView addSubview:_title];
-
- _title.sd_layout
- .leftSpaceToView(_image, 10)
- .heightIs(16)
- .topEqualToView(_image)
- .rightSpaceToView(self.contentView, 15);
-
- UILabel *line1 = [UILabel new];
- line1.backgroundColor = NewLineGrayColor;
- [self.contentView addSubview:line1];
-
- line1.sd_layout
- .leftEqualToView(_title)
- .topSpaceToView(line, 44)
- .heightIs(0.8)
- .rightEqualToView(self.contentView);
-
- _content = [UILabel new];
- _content.font = NewFont(fitScreenWidth(12));
- _content.textColor = [UIColor colorWithString:@"#9A9A9A"];
- _content.lineBreakMode = NSLineBreakByTruncatingTail;
- _content.numberOfLines = 3;
- [self.contentView addSubview:_content];
-
- _content.sd_layout
- .leftEqualToView(line1)
- .maxHeightIs(fitScreenWidth(50))
- .topSpaceToView(line1, 10)
- .rightSpaceToView(self.contentView, 15);
-
- UIImageView *followimage = [UIImageView new];
- [followimage setImage:NewImageNamed(@"关注")];
- [self.contentView addSubview:followimage];
-
- followimage.sd_layout
- .rightSpaceToView(self.contentView, 15)
- .heightIs(fitScreenWidth(16))
- .widthIs(fitScreenWidth(16))
- .bottomSpaceToView(self.contentView,5);
-
- _concernsnumber = [UILabel new];
- _concernsnumber.font = NewFont(fitScreenWidth(12));
- _concernsnumber.textColor = [UIColor colorWithString:@"#9A9A9A"];
- [_concernsnumber setSingleLineAutoResizeWithMaxWidth:0];
- [self.contentView addSubview:_concernsnumber];
-
- _concernsnumber.sd_layout
- .centerYEqualToView(followimage)
- .heightIs(16)
- .rightSpaceToView(followimage, 5);
- }
- return self;
- }
- - (void)assignment:(RecommendModel *)model {
- if (model.minLogoUrl == NULL) {
- [_image setImage:NewImageNamed(@"推荐默认")];
- }else{
- [_image sd_setImageWithURL:NewURL([model.minLogoUrl mosaicUrlPrefix]) placeholderImage:NewImageNamed(@"jz")];
- }
- _title.text = model.name;
- _content.text = model.introduce;
- _concernsnumber.text = model.interestCount;
- }
- - (void)awakeFromNib {
- [super awakeFromNib];
- // Initialization code
- }
- - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
- [super setSelected:selected animated:animated];
- // Configure the view for the selected state
- }
- @end
|