123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- //
- // FKProAskAnswerCell.m
- // FirstLink
- //
- // Created by jack on 16/8/13.
- // Copyright © 2016年 FirstLink. All rights reserved.
- //
- #import "FKProAskAnswerCell.h"
- #import "FKProDetailViewModel.h"
- @interface FKProAskAnswerCell ()
- @property (nonatomic, strong) UIImageView *askImgView;
- @property (nonatomic, strong) UIImageView *answerImgView;
- @property (nonatomic, strong) UILabel *askLabel;
- @property (nonatomic, strong) UILabel *anwserLabel;
- @end
- @implementation FKProAskAnswerCell
- - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
- if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
-
- [self addAllSubviews];
-
- self.contentView.backgroundColor = [UIColor whiteColor];
- self.selectionStyle = UITableViewCellSelectionStyleNone;
- }
- return self;
- }
- - (void)addAllSubviews{
-
- [self.contentView addSubview: self.askImgView];
- [self.contentView addSubview:self.answerImgView];
- [self.contentView addSubview:self.askLabel];
- [self.contentView addSubview:self.anwserLabel];
-
- [self.askImgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.contentView).offset(11);
- make.left.equalTo(self.contentView).offset(15);
- }];
-
- [self.answerImgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.bottom.equalTo(self.contentView).offset(- 11);
- make.left.equalTo(self.contentView).offset(15);
- }];
-
- [self.askLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.askImgView.mas_right).offset(5);
- make.right.equalTo(self.contentView).offset(- 15);
- make.centerY.equalTo(self.askImgView);
- }];
-
- [self.anwserLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.answerImgView.mas_right).offset(5);
- make.right.equalTo(self.contentView).offset(- 15);
- make.centerY.equalTo(self.answerImgView);
- }];
- }
- - (void)fk_configWithViewModel:(id)viewModel indexPath:(NSIndexPath *)indexPath{
- if ([viewModel isKindOfClass:[FKProDetailViewModel class]]) {
-
- FKProDetailViewModel *detailModel = (FKProDetailViewModel *)viewModel;
- self.askLabel.text = detailModel.dataItem.lastQA.questionDesc;
- self.anwserLabel.text = detailModel.dataItem.lastQA.answerDesc;
- }
- }
- + (CGFloat)cellHeight{
- return 72.0f;
- }
- - (UIImageView *)askImgView{
- if (_askImgView == nil) {
- _askImgView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"askImage"]];
- [_askImgView setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
- [_askImgView setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
- }
- return _askImgView;
- }
- - (UIImageView *)answerImgView{
- if (_answerImgView == nil) {
- _answerImgView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"answerImage"]];
- [_answerImgView setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
- [_answerImgView setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
- }
- return _answerImgView;
- }
- - (UILabel *)askLabel{
- if (_askLabel == nil) {
- _askLabel = [[UILabel alloc]init];
- _askLabel.font = [UIFont systemFontOfSize:13];
- _askLabel.textColor = UIColorFromRGB(0x333333);
- _askLabel.lineBreakMode = NSLineBreakByTruncatingTail;
- _askLabel.numberOfLines = 1;
- }
- return _askLabel;
- }
- - (UILabel *)anwserLabel{
- if (_anwserLabel == nil) {
- _anwserLabel = [[UILabel alloc]init];
- _anwserLabel.font = [UIFont systemFontOfSize:13];
- _anwserLabel.textColor = UIColorFromRGB(0x333333);
- _anwserLabel.lineBreakMode = NSLineBreakByTruncatingTail;
- _anwserLabel.numberOfLines = 1;
- }
- return _anwserLabel;
- }
- @end
|