|
//
// liveTopDateCell.m
// ThePaperHD
//
// Created by scar1900 on 15/3/10.
// Copyright (c) 2015年 scar1900. All rights reserved.
//
#import "liveTopDateCell.h"
@interface liveTopDateCell()
@property(nonatomic, strong)UILabel *topIconLabel;
@property(nonatomic, strong)UILabel *dateLabel;
@end
@implementation liveTopDateCell
@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 addSubview:self.topIconLabel];
[self addSubview:self.dateLabel];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(needrefreshNightMode:) name:REFRESHAFTERNIGHTMODE object:nil];
}
return self;
}
- (void)needrefreshNightMode:(id)sender{
self.backgroundColor = [UIColor colorWithHexString:BackGroundColor];
_topIconLabel.backgroundColor = [UIColor colorWithHexString:BLUECOLOR];
_dateLabel.backgroundColor = [UIColor colorWithHexString:BackGroundColor];
_dateLabel.textColor = [UIColor colorWithHexString:BLUECOLOR];
}
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (void)setDataDic:(NSDictionary *)dic {
_dataDic = dic;
NSString *date = dic[@"date"];
self.dateLabel.text = date;
[self layoutSubViews];
}
- (UILabel*)topIconLabel {
if (!_topIconLabel) {
_topIconLabel = [[UILabel alloc]initWithFrame:CGRectZero];
_topIconLabel.textAlignment = NSTextAlignmentCenter;
_topIconLabel.textColor = [UIColor whiteColor];
_topIconLabel.font = appFont(12, NO);
_topIconLabel.text = @"置顶";
_topIconLabel.backgroundColor = [UIColor colorWithHexString:BLUECOLOR];
}
return _topIconLabel;
}
- (UILabel*)dateLabel {
if (!_dateLabel) {
_dateLabel = [[UILabel alloc]initWithFrame:CGRectZero];
_dateLabel.textAlignment = NSTextAlignmentLeft;
_dateLabel.font = appFont(12, NO);
_dateLabel.backgroundColor = [UIColor colorWithHexString:BackGroundColor];
_dateLabel.textColor = [UIColor colorWithHexString:BLUECOLOR];
}
return _dateLabel;
}
- (void)layoutSubViews {
[self.topIconLabel remakeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.left).offset(10);
make.top.mas_equalTo(self.top).offset(20);
make.width.mas_equalTo(30);
make.height.mas_equalTo(15);
}];
[self.dateLabel remakeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.left).offset(50);
make.top.mas_equalTo(self.top).offset(20);
make.width.mas_equalTo(350/2);
make.height.mas_equalTo(15);
}];
}
- (void)awakeFromNib {
// Initialization code
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end
|