12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- //
- // FKProSpecResCell.m
- // FirstLink
- //
- // Created by jack on 16/8/12.
- // Copyright © 2016年 FirstLink. All rights reserved.
- //
- #import "FKProSpecResCell.h"
- #import "FKProDetailViewModel.h"
- @interface FKProSpecResCell ()
- @property (nonatomic, strong) UILabel *titleLabel;
- @property (nonatomic, strong) UILabel *specLabel;
- @property (nonatomic, strong) UIImageView *rightArrow;
- @end
- @implementation FKProSpecResCell
- - (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.titleLabel];
- [self.contentView addSubview:self.specLabel];
- [self.contentView addSubview:self.rightArrow];
-
- [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.contentView).offset(15);
- make.centerY.equalTo(self.contentView);
- }];
-
- [self.rightArrow mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.equalTo(self.contentView).offset(-15);
- make.centerY.equalTo(self.contentView);
- }];
-
- [self.specLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.equalTo(self.rightArrow.mas_left).offset(- 7);
- make.left.equalTo(self.titleLabel.mas_right).offset(10);
- make.centerY.equalTo(self.contentView);
- }];
- }
- - (void)fk_configWithViewModel:(id)viewModel indexPath:(NSIndexPath *)indexPath{
- if ([viewModel isKindOfClass:[FKProDetailViewModel class]]) {
-
- FKProDetailViewModel *detailModel = (FKProDetailViewModel *)viewModel;
- self.specLabel.text = detailModel.selectBuyItem.title;
- }
- }
- + (CGFloat)cellHeight{
- return 44.0f;
- }
- - (UILabel *)titleLabel{
- if (_titleLabel == nil) {
- _titleLabel = [[UILabel alloc]init];
- _titleLabel.textColor = UIColorFromRGB(0x666666);
- _titleLabel.font = [UIFont systemFontOfSize:14];
- _titleLabel.text = @"已选规格:";
- }
- return _titleLabel;
- }
- - (UILabel *)specLabel{
- if (_specLabel == nil) {
- _specLabel = [[UILabel alloc]init];
- _specLabel.textColor = UIColorFromRGB(0x333333);
- _specLabel.font = [UIFont systemFontOfSize:13];
- _specLabel.lineBreakMode = NSLineBreakByTruncatingTail;
- }
- return _specLabel;
- }
- - (UIImageView *)rightArrow{
- if (_rightArrow == nil) {
- _rightArrow = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"more_right_arrow"]];
- [_rightArrow setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
- [_rightArrow setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
- }
- return _rightArrow;
- }
- @end
|