12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- //
- // FKProWarnTitleCell.m
- // FirstLink
- //
- // Created by jack on 16/8/16.
- // Copyright © 2016年 FirstLink. All rights reserved.
- //
- #import "FKProWarnTitleCell.h"
- #import "FKProDetailViewModel.h"
- @interface FKProWarnTitleCell ()
- @property (nonatomic, strong) UIView *bottomLine;
- @end
- @implementation FKProWarnTitleCell
- - (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;
- }
- + (CGFloat)cellHeightForTitle:(NSString *)title lastRow:(BOOL)lastRow{
- CGFloat textH = [FLStringHelper sizeOfAttributeString:title
- font:[UIFont systemFontOfSize:13]
- width:UISCREENWIDTH - 30
- maxRow:INT_MAX].height;
-
- if (lastRow) return textH + 45;
- return textH + 30;
- }
- - (void)fk_configWithViewModel:(id)viewModel indexPath:(NSIndexPath *)indexPath{
- if ([viewModel isKindOfClass:[FKProDetailViewModel class]]) {
- FKProDetailViewModel *detailModel = (FKProDetailViewModel *)viewModel;
- NSString *title = [detailModel.tipsItem buyWarnTitleForIndexPath:indexPath];
- self.titleLabel.text = title;
-
- NSInteger count = [detailModel numberOfRowsInSection:indexPath.section tableType:kProTableTypeDown];
- self.bottomLine.hidden = NO;
- if (indexPath.row == count - 1) self.bottomLine.hidden = YES;
- }
- }
- - (void)addAllSubviews{
-
- [self.contentView addSubview:self.titleLabel];
- [self.contentView addSubview:self.bottomLine];
-
- [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.contentView).offset(10);
- make.left.equalTo(self.contentView).offset(15);
- make.right.equalTo(self.contentView).offset(-15);
- // make.centerY.equalTo(self.contentView);
- }];
-
- [self.bottomLine mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.contentView).offset(15);
- make.right.equalTo(self.contentView).offset(-15);
- make.bottom.equalTo(self.contentView);
- make.height.mas_equalTo(0.5);
- }];
- }
- - (UILabel *)titleLabel{
-
- if (_titleLabel == nil) {
- _titleLabel = [[UILabel alloc]init];
- _titleLabel.font = [UIFont systemFontOfSize:13];
- _titleLabel.textColor = UIColorFromRGB(0x666666);
- _titleLabel.numberOfLines = 0;
- }
- return _titleLabel;
- }
- - (UIView *)bottomLine {
- if (_bottomLine == nil) {
- _bottomLine = [[UIView alloc] init];
- _bottomLine.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"grey_lines"]];
- }
- return _bottomLine;
- }
- @end
|