澎湃iPad上线版本

otherPersonTopCell.m 4.3KB

    // // otherPersonTopCell.m // ThePaperBase // // Created by YoungLee on 15/10/8. // Copyright © 2015年 scar1900. All rights reserved. // #import "otherPersonTopCell.h" @interface otherPersonTopCell(){ CGFloat titleHeight; } @property(nonatomic, strong)UIView *backView; @property(nonatomic, strong)UILabel *typeLabel; @property(nonatomic, strong)UILabel *title; @end @implementation otherPersonTopCell @synthesize comment = _comment; @synthesize isTopic = _isTopic; -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{ self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { self.selectionStyle = UITableViewCellSelectionStyleNone; self.clipsToBounds = YES; self.backgroundColor = [UIColor colorWithHexString:BackGroundColor]; [self.contentView addSubview:self.backView]; [self.backView addSubview:self.typeLabel]; [self.backView addSubview:self.title]; } return self; } -(UIView *)backView{ if (!_backView) { _backView = [[UIView alloc] init]; } return _backView; } -(UILabel *)typeLabel{ if (!_typeLabel) { _typeLabel = [[UILabel alloc] init]; _typeLabel.backgroundColor = [UIColor colorWithHexString:BLUECOLOR]; _typeLabel.textColor = [UIColor colorWithHexString:BackGroundColor]; _typeLabel.font = appFont(TEXT_SIX_LEVELSIZE, NO); _typeLabel.textAlignment = NSTextAlignmentCenter; } return _typeLabel; } -(UILabel *)title{ if (!_title) { _title = [[UILabel alloc] init]; _title.backgroundColor = [UIColor colorWithHexString:CELLBACKCOLOR]; _title.font = appFont(TEXT_SIX_LEVELSIZE, NO); _title.numberOfLines = 0; _title.lineBreakMode = NSLineBreakByWordWrapping; _title.textColor = [UIColor colorWithHexString:TextLightGray]; } return _title; } -(void)setComment:(id)bo{ _comment = bo; if ([_comment isKindOfClass:[commentObjectVO class]]) { commentObjectVO *commentBo = bo; self.title.hidden = NO; self.typeLabel.text = [self setTypeName:commentBo.type]; // self.title.text = [self settitleName:commentBo]; self.title.attributedText = getLineSpaceAttributedString([self settitleName:commentBo], 2, appFont(TEXT_SIX_LEVELSIZE, NO)); }else{ self.title.hidden = YES; self.typeLabel.text = @"话题"; } } -(void)setIsTopic:(BOOL)isTop{ _isTopic = isTop; self.title.hidden = YES; self.typeLabel.text = @"话题"; } //1-跟帖,2-提问,3-回答 -(NSString *) setTypeName:(NSString *) typeStr{ NSString *str; switch ([typeStr integerValue]) { case 1: str = @"评论"; break; case 2: str = @"提问"; break; case 3: str = @"回答"; break; default: break; } return str; } //1- 新闻 2- 直播栏目 3- 话题 -(NSString*) settitleName:(commentObjectVO *) comment{ NSString *str; NSString *contName = comment.contName; NSString *contentName = comment.parent[@"content"]; if([comment.type isEqualToString:@"1"]){//如果是评论,后面只能是原新闻 str = [NSString stringWithFormat:@"【原新闻】%@",contName]; }else if ([comment.type isEqualToString:@"2"]){//如果是提问,后面只有两种:原话题,原新闻 if([comment.objectType isEqualToString:@"3"]){ str = [NSString stringWithFormat:@"【原话题】%@",contName]; }else{ str = [NSString stringWithFormat:@"【原新闻】%@",contName]; } }else{ str = [NSString stringWithFormat:@"【原提问】%@",contentName]; } titleHeight = heightForAttributeStringWithLabel(getLineSpaceAttributedString(str, 2, appFont(TEXT_SIX_LEVELSIZE, NO)), 688, appFont(TEXT_SIX_LEVELSIZE, NO)); if (titleHeight < 20) { titleHeight = 20; } return str; } -(void)layoutSubviews{ [super layoutSubviews]; self.backView.frame = CGRectMake(CGRectGetWidth(self.bounds)/2-768/2, 0, 768, CGRectGetMaxY(self.bounds)); self.typeLabel.frame = CGRectMake(20, 10, 40, titleHeight); self.title.frame = CGRectMake(CGRectGetMaxX(self.typeLabel.frame), 10, 688, titleHeight); } @end