|
//
// otherPersonTopCell.m
// ThePaperBase
//
// Created by YoungLee on 15/11/24.
// Copyright © 2015年 scar1900. All rights reserved.
//
#import "otherPersonTopCell.h"
@implementation otherPersonTopCell
@synthesize comment = _comment;
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
self.backgroundColor = [UIColor colorWithHexString:CELLBACKCOLOR];
self.selectionStyle = UITableViewCellSelectionStyleNone;
self.markLabel.hidden = YES;
[self.backView addSubview:self.typeImg];
[self.backView addSubview:self.typeLabel];
}
return self;
}
-(UIImageView *)typeImg{
if (!_typeImg) {
_typeImg = [UIImageView new];
_typeImg.image = Image(@"topic/otherType.png");
}
return _typeImg;
}
-(UILabel *)typeLabel{
if (!_typeLabel) {
_typeLabel = [[UILabel alloc] init];
_typeLabel.backgroundColor = [UIColor clearColor];
_typeLabel.textColor = [UIColor whiteColor];
_typeLabel.font = appFont(TEXT_SIX_LEVELSIZE, NO);
_typeLabel.textAlignment = NSTextAlignmentCenter;
}
return _typeLabel;
}
#pragma mark -- data
-(void)setComment:(commentObjectVO *)commentBO{
_comment = commentBO;
// NSString *topTitle;
// if([_comment.objectType intValue] == 3){
// topTitle = [NSString stringWithFormat:@"【原话题】%@",_comment.contName];
// }else{
// topTitle = [NSString stringWithFormat:@"【原新闻】%@",_comment.contName];
// }
self.titileLabel.attributedText = getLineSpaceAttributedString([self settitleName:_comment], 3, appFont(TEXT_SIX_LEVELSIZE, NO));
self.typeLabel.text = [self setTypeName:_comment.type];
[self setLayout];
}
//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];
}
return str;
}
-(void)setLayout{
[self.backView makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.contentView.left).offset(10);
make.right.equalTo(self.contentView.right).offset(-10);
make.top.equalTo(self.contentView.top).offset(10);
make.bottom.equalTo(self.contentView.bottom);
}];
[self.titileLabel makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.backView.left).offset(5);
make.right.equalTo(self.backView.right).offset(-15);
make.top.equalTo(self.backView.top).offset(5);
make.bottom.equalTo(self.backView.bottom).offset(-6);
}];
[self.lineView makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.backView.left);
make.right.equalTo(self.backView.right);
make.top.equalTo(self.backView.bottom).offset(-1);
make.height.mas_equalTo(0.5);
}];
[self.typeImg makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.backView.right).offset(5);
make.width.equalTo(@25);
make.top.equalTo(self.backView.top).offset(-5);
make.height.equalTo(@25);
}];
[self.typeLabel makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.typeImg.left).offset(5);
make.right.equalTo(self.typeImg.right);
make.top.equalTo(self.typeImg.top);
make.bottom.equalTo(self.typeImg.bottom).offset(-5);
}];
}
@end
|