|
//
// hotTopicListCardCell.m
// ThePaperBase
//
// Created by scar1900 on 15/7/30.
// Copyright (c) 2015年 scar1900. All rights reserved.
//
#import "hotTopicListCardCell.h"
@interface hotTopicListCardCell()
@property(nonatomic, strong)UIView *backView;
@property(nonatomic, strong)RTLabel *titleLabel;
@property(nonatomic, strong)UIView *lineView;
@end
@implementation hotTopicListCardCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
self.contentView.backgroundColor = [UIColor colorWithHexString:CELLBACKCOLOR];
[self.contentView addSubview:self.backView];
[self.backView addSubview:self.titleLabel];
[self.backView addSubview:self.lineView];
UIView *selectView = [[UIView alloc]initWithFrame:CGRectMake(10, 0, CGRectGetWidth(self.bounds)-20, CGRectGetHeight(self.bounds))];
selectView.backgroundColor = [UIColor colorWithHexString:CELLBACKCOLOR];
self.selectedBackgroundView = selectView;
[self.backView makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.contentView.left).offset(10);
make.right.equalTo(self.contentView.right).offset(-10);
make.top.equalTo(self.contentView.top);
make.bottom.equalTo(self.contentView.bottom);
}];
UIEdgeInsets edge = UIEdgeInsetsMake(19, 10, 19, 10);
[self.titleLabel remakeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self.backView).offset(edge);
}];
[self.lineView makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.backView.left);
make.right.equalTo(self.backView.right);
make.bottom.equalTo(self.backView.bottom);
make.height.equalTo(@1);
}];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(needrefreshNightMode:) name:REFRESHAFTERNIGHTMODE object:nil];
}
return self;
}
- (UIView*)lineView {
if (!_lineView) {
_lineView = [UIView new];
_lineView.backgroundColor = [UIColor colorWithHexString:LINECOLOR];
}
return _lineView;
}
- (UIView*)backView {
if (!_backView) {
_backView = [UIView new];
_backView.backgroundColor = [UIColor colorWithHexString:BackGroundColor];
}
return _backView;
}
- (RTLabel*)titleLabel {
if (!_titleLabel) {
_titleLabel = [RTLabel new];
_titleLabel.backgroundColor = [UIColor colorWithHexString:BackGroundColor];
_titleLabel.textAlignment = RTTextAlignmentLeft;
_titleLabel.textColor = [UIColor colorWithHexString:TextBlack];
_titleLabel.lineBreakMode = RTTextLineBreakModeWordWrapping;
}
return _titleLabel;
}
- (void)setTopicBO:(TopicInfoBO *)data {
_topicBO = data;
self.titleLabel.text = data.title;
self.titleLabel.font = appFont(TEXT_TWO_LEVELSIZE, NO);
}
- (void)needrefreshNightMode:(id)sender{
self.contentView.backgroundColor = [UIColor colorWithHexString:CELLBACKCOLOR];
self.backView.backgroundColor = [UIColor colorWithHexString:BackGroundColor];
UIView *selectView = [[UIView alloc]initWithFrame:CGRectMake(10, 0, CGRectGetWidth(self.bounds)-20, CGRectGetHeight(self.bounds))];
selectView.backgroundColor = [UIColor colorWithHexString:CELLBACKCOLOR];
self.selectedBackgroundView = selectView;
self.titleLabel.backgroundColor = [UIColor colorWithHexString:BackGroundColor];
self.titleLabel.textColor = [UIColor colorWithHexString:TextBlack];
self.lineView.backgroundColor = [UIColor colorWithHexString:LINECOLOR];
}
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
@end
|