|
//
// contentTextCell.m
// ThePaperDemo
//
// Created by scar1900 on 14/11/5.
// Copyright (c) 2014年 scar1900. All rights reserved.
//
#import "contentTextCell.h"
@interface contentTextCell() {
CGFloat contentHeight;
}
@property(nonatomic, strong)UITextView *contentLabel;
@end
@implementation contentTextCell
@synthesize text = _text;
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
self.backgroundColor = [UIColor colorWithHexString:BackGroundColor];
// self.backgroundColor = [UIColor greenColor];
self.selectionStyle = UITableViewCellSelectionStyleNone;
[self.contentView addSubview:self.contentLabel];
[self setAutoLayoutSubviews];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(statusBarOrientationChange:) name:UIApplicationDidChangeStatusBarOrientationNotification object:nil];
}
return self;
}
- (UITextView*)contentLabel {
if (!_contentLabel) {
_contentLabel = [[UITextView alloc]initWithFrame:CGRectMake(0, 0, 1320/2, 0)];
_contentLabel.backgroundColor = [UIColor colorWithHexString:BackGroundColor];
[_contentLabel setEditable:NO];
_contentLabel.textAlignment = NSTextAlignmentLeft;
_contentLabel.scrollEnabled = NO;
_contentLabel.showsVerticalScrollIndicator = NO;
_contentLabel.showsHorizontalScrollIndicator = NO;
}
return _contentLabel;
}
- (void)setText:(NSAttributedString *)str {
if (_text != str) {
_text = str;
// self.contentLabel.attributeStr = str;
self.contentLabel.attributedText = str;
[self.contentLabel setNeedsDisplay];
[self setAutoLayoutSubviews];
}
}
- (void)statusBarOrientationChange:(NSNotification *)notification{
CGFloat padding = 0;
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
if (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight) {
padding = 125;
}
[self.contentLabel remakeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.contentView.top).offset(0);
make.left.equalTo(self.contentView.left).offset(padding);
make.width.mas_equalTo(1320/2);
make.bottom.mas_equalTo(self.contentView.bottom).offset(-[ipadLineAndParaSpace newsColumSpace]);
}];
}
- (void)setAutoLayoutSubviews {
CGFloat padding = 0;
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
if (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight) {
padding = 125;
}
[self.contentLabel remakeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.contentView.top).offset(0);
make.left.equalTo(self.contentView.left).offset(padding);
make.width.mas_equalTo(1320/2);
make.bottom.mas_equalTo(self.contentView.bottom).offset(-[ipadLineAndParaSpace newsColumSpace]);
}];
}
- (void)awakeFromNib {
// Initialization code
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end
|