123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- //
- // FKCircleDescCell.m
- // FirstLink
- //
- // Created by jack on 16/6/12.
- // Copyright © 2016年 FirstLink. All rights reserved.
- //
- #import "FKCircleDescCell.h"
- #import "FKCircleBestViewModel.h"
- @interface FKCircleDescCell ()
- @property (nonatomic, strong) UIView *containerView;
- @property (nonatomic, strong) UIView *cornerCoverView;
- @end
- @implementation FKCircleDescCell
- - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
- if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
-
- [self addAllSubviews];
- self.selectionStyle = UITableViewCellSelectionStyleNone;
- self.backgroundColor = [UIColor clearColor];
- }
- return self;
- }
- - (void)addAllSubviews{
-
- [self.contentView addSubview:self.containerView];
- [self.contentView addSubview:self.cornerCoverView];
-
- [self.containerView addSubview:self.titleLabel];
-
- [self.containerView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.edges.insets(UIEdgeInsetsMake(0, 5, 0, 5));
- }];
-
- [self.cornerCoverView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.top.equalTo(self.containerView);
- make.height.mas_equalTo(8);
- }];
-
- [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.containerView).offset(11);
- make.left.equalTo(self.containerView).offset(12);
- make.right.equalTo(self.containerView).offset(- 12);
- }];
- }
- - (void)fk_configWithViewModel:(id)viewModel indexPath:(NSIndexPath *)indexPath{
- if ([viewModel isKindOfClass:[FKCircleBestViewModel class]]) {
-
- FKCircleBestViewModel *bestViewModel = (FKCircleBestViewModel *)viewModel;
- FKCircleContentItem *contentItem = [bestViewModel circleContentItemForIndexPath:indexPath];
- self.titleLabel.text = contentItem.shareItem.desc;
-
- NSInteger rowCount = [bestViewModel numberOfRowsInSection:indexPath.section];
- [self setLastLine:indexPath.row == rowCount - 1];
- }
- }
- + (CGFloat)cellHeightForTitle:(NSString *)title{
- if (title.length == 0) return 15;
-
- CGFloat textH = [FLStringHelper sizeOfAttributeString:title
- font:[UIFont systemFontOfSize:14]
- width:UISCREENWIDTH - 34 maxRow:2].height;
- return textH + 25;
- }
- - (void)setLastLine:(BOOL)lastLine{
- // 最后一行圆角
- self.containerView.layer.cornerRadius = 0.0f;
- self.cornerCoverView.hidden = YES;
-
- if (lastLine){
- self.containerView.layer.cornerRadius = 4.0f;
- self.cornerCoverView.hidden = NO;
- }
- }
- - (UIView *)containerView{
- if (_containerView == nil) {
- _containerView = [[UIView alloc]init];
- _containerView.backgroundColor = [UIColor whiteColor];
- }
- return _containerView;
- }
- - (UIView *)cornerCoverView{
- if (_cornerCoverView == nil) {
- _cornerCoverView = [[UIView alloc]init];
- _cornerCoverView.backgroundColor = [UIColor whiteColor];
- }
- return _cornerCoverView;
- }
- - (UILabel *)titleLabel{
- if (_titleLabel == nil) {
- _titleLabel = [[UILabel alloc]init];
- _titleLabel.textColor = UIColorFromRGB(0x000000);
- _titleLabel.font = [UIFont systemFontOfSize:14];
- _titleLabel.numberOfLines = 2;
- _titleLabel.lineBreakMode = NSLineBreakByTruncatingTail;
- }
- return _titleLabel;
- }
- @end
|