|
//
// moreTableViewCell.m
// ThePaperDemo
//
// Created by zhousan on 15/7/16.
// Copyright (c) 2015年 scar1900. All rights reserved.
//
#import "moreTableViewCell.h"
#define CONTENT_WIDTH rect_screen.size.width - 35
#define ROUNDVIEW_TAG 10086
@interface moreTableViewCell () {
CGFloat contentHeight;
}
@property (nonatomic, strong) RTLabel *contentLabel;
@property (nonatomic, strong) UILabel *timeLabel;
@property (nonatomic, strong) UIView *lineView;
@end
@implementation moreTableViewCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (nil != self) {
self.backgroundColor = [UIColor colorWithHexString:BackGroundColor];
[self.contentView addSubview:self.timeLabel];
[self.contentView addSubview:self.contentLabel];
UIView *roundView = [[UIView alloc] initWithFrame:CGRectMake(10, 24, 5, 5)];
/**
* bug:5243(专题页-更多,左边的点都偏上了)
*/
roundView.tag = ROUNDVIEW_TAG;
roundView.layer.cornerRadius = 5;
roundView.layer.masksToBounds = YES;
roundView.backgroundColor = [UIColor colorWithHexString:@"0xd1d2d3"];
[self.contentView addSubview:roundView];
[self.contentView addSubview:self.lineView];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(needrefreshNightMode:) name:REFRESHAFTERNIGHTMODE object:nil];
}
return self;
}
- (void)needrefreshNightMode:(id)sender{
self.backgroundColor = [UIColor colorWithHexString:BackGroundColor];
_lineView.backgroundColor = [UIColor colorWithHexString:LINECOLOR];
_contentLabel.textColor = [UIColor colorWithHexString:TextBlack];
_timeLabel.textColor = [UIColor colorWithHexString:LiveSectionHeaderColor];
[_contentLabel setNeedsDisplay];
}
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
#pragma mark - setter
- (void)setContentString:(NSString *)contentString {
if (_contentString != contentString) {
_contentString = contentString;
self.contentLabel.text = _contentString;
contentHeight = self.contentLabel.optimumSize.height;
[self layoutSubViews];
}
}
- (UIView *)lineView {
if (!_lineView) {
_lineView = [[UIView alloc] initWithFrame:CGRectZero];
_lineView.backgroundColor = [UIColor colorWithHexString:LINECOLOR];
}
return _lineView;
}
- (void)setTimeString:(NSString *)timeString {
if (_timeString != timeString) {
_timeString = timeString;
self.timeLabel.text = timeString;
}
}
#pragma mark - getter
- (RTLabel*)contentLabel {
if (!_contentLabel) {
_contentLabel = [[RTLabel alloc]initWithFrame:CGRectMake(10, 0, CONTENT_WIDTH, 0)];
_contentLabel.textColor = [UIColor colorWithHexString:TextBlack];
_contentLabel.textAlignment = RTTextAlignmentLeft;
_contentLabel.lineBreakMode = NSLineBreakByWordWrapping;
_contentLabel.lineSpacing = 10;
}
_contentLabel.font = appFont(TEXT_FOUR_LEVELSIZE, NO);
return _contentLabel;
}
- (UILabel *)timeLabel {
if (_timeLabel == nil) {
_timeLabel =[[UILabel alloc] initWithFrame:CGRectZero];
_timeLabel.textAlignment = NSTextAlignmentLeft;
_timeLabel.font = appFont(TEXT_SIX_LEVELSIZE, NO);
_timeLabel.textColor = [UIColor colorWithHexString:LiveSectionHeaderColor];
}
return _timeLabel;
}
- (void)layoutSubViews {
[self.contentLabel remakeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.contentView.left).offset(24);
make.right.equalTo(self.contentView.right).offset(-9);
make.height.mas_equalTo(contentHeight);
make.top.equalTo(self.contentView.top).offset(18);
}];
[self.timeLabel remakeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.contentLabel.left);
make.right.equalTo(self.contentLabel.right);
make.top.equalTo(self.contentLabel.bottom).offset(12);
make.bottom.equalTo(self.contentView.bottom).offset(-3);
}];
[self.lineView remakeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.contentLabel.left);
make.right.equalTo(self.contentLabel.right);
make.top.equalTo(self.contentView.bottom).offset(-1);
make.height.mas_equalTo(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
|