1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- //
- // FKCirDetailImgDescCell.m
- // FirstLink
- //
- // Created by jack on 16/6/16.
- // Copyright © 2016年 FirstLink. All rights reserved.
- //
- #import "FKCirDetailImgDescCell.h"
- #import "FKCircleDetailViewModel.h"
- @interface FKCirDetailImgDescCell ()
- @property (nonatomic, strong) UILabel *titleLabel;
- @end
- @implementation FKCirDetailImgDescCell
- - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
- if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
-
- [self addAllSubviews];
- self.selectionStyle = UITableViewCellSelectionStyleNone;
- self.contentView.backgroundColor = [UIColor whiteColor];
- }
- return self;
- }
- - (void)addAllSubviews{
-
- [self.contentView addSubview:self.proImgView];
- [self.contentView addSubview:self.titleLabel];
-
- [self.proImgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.left.right.equalTo(self.contentView);
- make.height.mas_equalTo(UISCREENWIDTH);
- }];
-
- [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.proImgView.mas_bottom).offset(15);
- make.left.equalTo(self.contentView).offset(15);
- make.right.equalTo(self.contentView).offset(- 15);
- }];
- }
- + (CGFloat)cellHeightForTitle:(NSString *)title{
- if (!title.length) return UISCREENWIDTH;
- CGFloat descH = [FLStringHelper sizeOfAttributeString:title
- lineSpace:2.5
- width:UISCREENWIDTH - 30
- font:[UIFont systemFontOfSize:14]
- maxRow:NSIntegerMax].height;
- return descH + 30 + UISCREENWIDTH;
- }
- - (void)fk_configWithViewModel:(id)viewModel indexPath:(NSIndexPath *)indexPath{
- if ([viewModel isKindOfClass:[FKCircleDetailViewModel class]]) {
- FKCircleDetailViewModel *cirViewModel = (FKCircleDetailViewModel *)viewModel;
- FKCirDetailContentItem *contentItem = [cirViewModel.dataItem contentDetailItemForIndex:indexPath.row];
- [self.proImgView setImageWithURL:contentItem.contentData.picUrl cdnWidth:UISCREENWIDTH];
- self.titleLabel.text = contentItem.contentData.contentText;
- }
- }
- #pragma mark - property
- - (UIImageView *)proImgView{
- if (_proImgView == nil) {
- _proImgView = [[UIImageView alloc]init];
- _proImgView.contentMode = UIViewContentModeScaleAspectFit;
- }
- return _proImgView;
- }
- - (UILabel *)titleLabel{
- if (_titleLabel == nil) {
- _titleLabel = [[UILabel alloc]init];
- _titleLabel.font = [UIFont systemFontOfSize:14];
- _titleLabel.textColor = UIColorFromRGB(0x333333);
- _titleLabel.numberOfLines = 0;
- }
- return _titleLabel;
- }
- @end
|