//
// specialTopicHeadCell.m
// ThePaperHD
//
// Created by scar1900 on 15/2/13.
// Copyright (c) 2015年 scar1900. All rights reserved.
//
#import "specialTopicHeadCell.h"
#import "AsyncImageView.h"
#define LINETAG 3000
@interface specialTopicHeadCell() {
CGFloat descHeight;
NSInteger numOfLine;
}
@property(nonatomic, strong)AsyncImageView *headImageView;
@property(nonatomic, strong)RTLabel *headDescLabel;
@end
@implementation specialTopicHeadCell
@synthesize specialBO = _specialBO;
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
self.backgroundColor = [UIColor clearColor];
self.selectionStyle = UITableViewCellSelectionStyleNone;
[self addSubview:self.headImageView];
[self addSubview:self.headDescLabel];
}
return self;
}
- (void)setSpecialBO:(specialObjectBO *)specialBO {
_specialBO = specialBO;
self.headImageView.imageUrl = specialBO.pic;
NSString *descStr = @"导读 | ";
descStr = [descStr stringByAppendingString:specialBO.desc];
descHeight = returnTextHeightWithRTLabel(descStr,
1320/2,
appFont(18, NO),
20)+5;//bug fixed:(4585)专题页,导读显示不全,进入一个查看更多头两个卡片也显示专题
self.headDescLabel.text = descStr;
// [self.subviews enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
// if ([obj isKindOfClass:[UIView class]]) {
// UIView *subView = obj;
// if (subView.tag >= 3000) {
// [subView removeFromSuperview];
// }
// }
// }];
[self layoutSubView];
}
- (RTLabel*)headDescLabel {
if (!_headDescLabel) {
_headDescLabel = [[RTLabel alloc]initWithFrame:CGRectZero];
_headDescLabel.textAlignment = RTTextAlignmentLeft;
_headDescLabel.font = appFont(18, NO);
_headDescLabel.lineSpacing = 20;
_headDescLabel.textColor = [UIColor colorWithHexString:TextBlack];
}
return _headDescLabel;
}
- (AsyncImageView*)headImageView {
if (!_headImageView) {
_headImageView = [[AsyncImageView alloc]initWithFrame:CGRectZero];
_headImageView.backgroundColor = [UIColor clearColor];
_headImageView.hidden = YES;
}
return _headImageView;
}
- (void)layoutSubView {
CGFloat oneLine = returnTextHeightWithRTLabel(@"高度", 100, appFont(18, NO), 20)+20;
numOfLine = descHeight/oneLine+1;
for (NSInteger i =0;i