|
//
// liveContentCell.m
// ThePaperHD
//
// Created by scar1900 on 15/3/11.
// Copyright (c) 2015年 scar1900. All rights reserved.
//
#import "liveContentCell.h"
#define CONTENTWIDTH 1060/2
@interface liveContentCell() {
CGFloat contentHeight;
}
@property(nonatomic, strong)UILabel *contentLabel;
@property(nonatomic, strong)UIView *lineView;
@end
@implementation liveContentCell
@synthesize dataDic = _dataDic;
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
self.backgroundColor = [UIColor colorWithHexString:BackGroundColor];
self.selectionStyle = UITableViewCellSelectionStyleNone;
[self.contentView addSubview:self.contentLabel];
[self.contentView addSubview:self.lineView];
}
return self;
}
-(UILabel *)contentLabel{
if (!_contentLabel) {
_contentLabel = [[UILabel alloc]initWithFrame:CGRectZero];
_contentLabel.backgroundColor = [UIColor colorWithHexString:BackGroundColor];
_contentLabel.textAlignment = NSTextAlignmentLeft;
_contentLabel.numberOfLines = 0;
_contentLabel.lineBreakMode = NSLineBreakByWordWrapping;
_contentLabel.backgroundColor = [UIColor clearColor];
}
return _contentLabel;
}
- (UIView*)lineView {
if (!_lineView) {
_lineView = [[UIView alloc]initWithFrame:CGRectZero];
_lineView.backgroundColor = [UIColor colorWithHexString:LINECOLOR];
}
return _lineView;
}
- (void)setDataDic:(NSDictionary *)dic {
_dataDic = dic;
NSAttributedString *str = dic[@"text"];
self.contentLabel.attributedText = str;
NSString *type = dic[@"type"];
if ([type isMatchedByRegex:@"top"]) {
self.lineView.hidden = YES;
}else self.lineView.hidden = NO;
// contentHeight = heightForAttributeStringWithLabel(str, CONTENTWIDTH, appFont([TPUserDefault instance].contFontSize, NO));
//
}
- (void)layoutSubviews {
CGFloat padding = 0;
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
if (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight) {
padding = 125;
}
[self.contentLabel remakeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.left).offset(padding+226/2);
make.width.mas_equalTo(CONTENTWIDTH);
make.top.equalTo(self.top);
make.bottom.equalTo(self.bottom).offset(-[ipadLineAndParaSpace liveColumSpace]);
}];
[self.lineView remakeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.contentView.left).offset(padding+7);
make.width.mas_equalTo(1);
make.top.equalTo(self.top);
make.bottom.equalTo(self.bottom);
}];
[super layoutSubviews];
}
- (void)awakeFromNib {
// Initialization code
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end
|