|
//
// 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 = @"<font color='#00a5eb'>导读 | </font>";
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<numOfLine;i++) {
UIView *lineView = [[UIView alloc]initWithFrame:CGRectZero];
lineView.backgroundColor = [UIColor colorWithHexString:LINECOLOR];
lineView.tag = LINETAG + i;
[self addSubview:lineView];
}
CGFloat padding = 0;
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
if (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight) {
padding = 125;
}
self.headImageView.frame = CGRectMake(padding, 0, 1320/2, 350/2);
if (self.headImageView.hidden) {
self.headImageView.hidden = NO;
}
self.headDescLabel.frame = CGRectMake(padding, CGRectGetMaxY(self.headImageView.frame)+15, CGRectGetWidth(self.headImageView.frame), descHeight);
for (NSInteger i=0; i<numOfLine; i++) {
UIView *lineView = [self viewWithTag:LINETAG+i];
lineView.frame = CGRectMake(padding, CGRectGetMinY(self.headDescLabel.frame)+(i+1)*(oneLine + 2) - 16, CGRectGetWidth(self.headDescLabel.frame), 1);
}
}
- (void)awakeFromNib {
// Initialization code
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end
|