123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- //
- // FKProWarnHeaderView.m
- // FirstLink
- //
- // Created by jack on 16/8/16.
- // Copyright © 2016年 FirstLink. All rights reserved.
- //
- #import "FKProWarnHeaderCell.h"
- #import "FKProDetailViewModel.h"
- @interface FKProWarnHeaderCell ()
- @property (nonatomic, strong) UIView *titleBgView;
- @property (nonatomic, strong) UIView *middleLine;
- @end
- @implementation FKProWarnHeaderCell
- - (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.backgroundColor = [UIColor whiteColor];
-
- [self.contentView addSubview:self.titleBgView];
- [self.contentView addSubview:self.middleLine];
- [self.contentView addSubview:self.titleLabel];
-
- [self.middleLine mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.contentView).offset(15);
- make.right.equalTo(self.contentView).offset(- 15);
- make.centerY.equalTo(self.titleBgView);
- make.height.mas_equalTo(0.5);
- }];
-
- [self.titleBgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.contentView).offset(20);
- make.centerX.equalTo(self.contentView);
- make.height.mas_equalTo(20);
- make.width.equalTo(self.titleLabel).offset(30);
- }];
-
- [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.center.equalTo(self.titleBgView);
- }];
- }
- - (void)fk_configWithViewModel:(id)viewModel indexPath:(NSIndexPath *)indexPath{
- if ([viewModel isKindOfClass:[FKProDetailViewModel class]]) {
-
- NSString *title = nil;
- if (indexPath.section == 0) title = @"买前必看";
- if (indexPath.section == 1) title = @"注意事项";
- if (indexPath.section == 2) title = @"购物流程";
- self.titleLabel.text = title;
- }
- }
- + (CGFloat)cellHeight{
- return 48.0f;
- }
- - (UILabel *)titleLabel{
- if (_titleLabel == nil) {
- _titleLabel = [[UILabel alloc]init];
- _titleLabel.font = [UIFont systemFontOfSize:15];
- _titleLabel.textColor = [UIColor whiteColor];
- [_titleLabel setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
- [_titleLabel setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
- }
- return _titleLabel;
- }
- - (UIView *)titleBgView{
- if (_titleBgView == nil) {
- _titleBgView = [[UIView alloc]init];
- _titleBgView.backgroundColor = UIColorFromRGB(0x444444);
- }
- return _titleBgView;
- }
- - (UIView *)middleLine{
- if (_middleLine == nil) {
- _middleLine = [[UIView alloc]init];
- _middleLine.backgroundColor = UIColorFromRGB(0x444444);
- }
- return _middleLine;
- }
- @end
|