|
//
// searchCell.m
// ThePaperBase
//
// Created by Huixin on 15/7/27.
// Copyright (c) 2015年 scar1900. All rights reserved.
//
#import "searchCell.h"
@interface searchCell()
@property(nonatomic, strong)RTLabel *titleLabel;
@property(nonatomic, strong)UILabel *timeLabel;
@property(nonatomic, strong)UIView *line;
@end
@implementation searchCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
self.backgroundColor = [UIColor clearColor];
UIView *selectView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.bounds), CGRectGetHeight(self.bounds))];
selectView.backgroundColor = [UIColor colorWithHexString:CELLBACKCOLOR];
self.selectedBackgroundView = selectView;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(needrefreshNightMode) name:REFRESHAFTERNIGHTMODE object:nil];
[self.contentView addSubview:self.titleLabel];
[self.contentView addSubview:self.timeLabel];
[self.contentView addSubview:self.line];
[self.titleLabel makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.contentView.top).offset(10);
make.left.equalTo(self.contentView.left).offset(10);
make.right.equalTo(self.contentView.right).offset(-10);
}];
[self.timeLabel makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.titleLabel.bottom).offset(10);
make.left.equalTo(self.contentView.left).offset(10);
make.right.equalTo(self.contentView.right).offset(-10);
make.height.mas_equalTo(@10);
}];
[self.line makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.timeLabel.bottom).offset(5.5);
make.left.equalTo(self.contentView.left).offset(10);
make.right.equalTo(self.contentView.right);
make.bottom.equalTo(self.contentView.bottom);
make.height.mas_equalTo(@0.5);
}];
}
return self;
}
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (void)needrefreshNightMode {
UIView *selectView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.bounds), CGRectGetHeight(self.bounds))];
selectView.backgroundColor = [UIColor colorWithHexString:CELLBACKCOLOR];
self.selectedBackgroundView = selectView;
[self layoutSubviews]; //bug5058: 夜间模式实时切换
}
- (void)layoutSubviews {
[super layoutSubviews];
self.titleLabel.text = self.titleLabel.text;
self.timeLabel.textColor = [UIColor colorWithHexString:TextGray];
self.line.backgroundColor = [UIColor colorWithHexString:LINECOLOR];
}
- (RTLabel*)titleLabel {
if (!_titleLabel) {
_titleLabel = [[RTLabel alloc] init];
_titleLabel.font = appFont(TEXT_THREE_LEVELSIZE, NO);
_titleLabel.lineSpacing = 7;
_titleLabel.backgroundColor = [UIColor clearColor];
_titleLabel.lineBreakMode = RTTextLineBreakModeWordWrapping;
}
_titleLabel.textColor = [UIColor colorWithHexString:TextBlack];
return _titleLabel;
}
- (UILabel*)timeLabel {
if (!_timeLabel) {
_timeLabel = [[UILabel alloc] init];
_timeLabel.font = appFont(TEXT_SEVEN_LEVELSIZE, NO);
_timeLabel.backgroundColor = [UIColor clearColor];
_timeLabel.textColor = [UIColor colorWithHexString:TextGray];
}
return _timeLabel;
}
- (UIView*)line {
if (!_line) {
_line = [UIView new];
_line.backgroundColor = [UIColor colorWithHexString:LINECOLOR];
}
return _line;
}
- (void)setData:(listContObjectVO *)listBO key:(NSArray *)key {
__block NSString *name = listBO.name;
[key enumerateObjectsUsingBlock:^(NSString* obj, NSUInteger idx, BOOL *stop) {
if ([name isMatchedByRegex:obj]){
name = [name stringByReplacingOccurrencesOfString:obj withString:[NSString stringWithFormat:@"<font color='#00a5eb'>%@</font><N>",obj]];
}
}];
self.titleLabel.text = name;
self.timeLabel.text = listBO.pubTime;
}
@end
|