|
//
// relateNewCell.m
// ThePaperDemo
//
// Created by scar1900 on 14-9-23.
// Copyright (c) 2014年 scar1900. All rights reserved.
//
#import "relateNewCell.h"
@interface relateNewCell() {
CGFloat contentPadding;
}
@property(nonatomic, strong)UILabel *relateTextLabel;
@property(nonatomic, strong)UIView *lineView;
@end
@implementation relateNewCell
@synthesize listBO=_listBO;
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
if (IS_IPHONE_6P) {
contentPadding = 15;
}else if (IS_IPHONE_6) {
contentPadding = 15;
}else {
contentPadding = 10;
}
self.backgroundColor = [UIColor colorWithHexString:ContentDetailBack];
// self.selectionStyle = UITableViewCellSelectionStyleGray;
[self.contentView addSubview:self.relateTextLabel];
[self.contentView 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 setLayoutSubviews];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(needrefreshNightMode:) name:REFRESHAFTERNIGHTMODE object:nil];
}
return self;
}
- (void)needrefreshNightMode:(id)sender{
UIView *selectView = [[UIView alloc]initWithFrame:CGRectMake(contentPadding, 0, CGRectGetWidth(self.bounds)-2*contentPadding, CGRectGetHeight(self.bounds))];
selectView.backgroundColor = [UIColor colorWithHexString:CELLBACKCOLOR];
self.selectedBackgroundView = selectView;
self.backgroundColor = [UIColor colorWithHexString:ContentDetailBack];
_lineView.backgroundColor = [UIColor colorWithHexString:LINECOLOR];
_relateTextLabel.textColor = [UIColor colorWithHexString:TextBlack];
}
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
self.relateTextLabel = nil;
self.lineView = nil;
}
- (UILabel*)relateTextLabel {
if (!_relateTextLabel) {
_relateTextLabel = [[UILabel alloc]initWithFrame:CGRectZero];
_relateTextLabel.textColor = [UIColor colorWithHexString:TextBlack];
_relateTextLabel.textAlignment = NSTextAlignmentLeft;
_relateTextLabel.lineBreakMode = NSLineBreakByWordWrapping;
_relateTextLabel.numberOfLines = 0;
_relateTextLabel.backgroundColor = [UIColor clearColor];
// _relateTextLabel.font = appFont(TEXT_THREE_LEVELSIZE, NO);
}
return _relateTextLabel;
}
- (UIView*)lineView {
if (!_lineView) {
_lineView = [[UIView alloc]initWithFrame:CGRectZero];
_lineView.backgroundColor = [UIColor colorWithHexString:LINECOLOR];
}
return _lineView;
}
- (void)setListBO:(listContObjectVO *)dataBO {
if ([dataBO isKindOfClass:[listContObjectVO class]]) {
_listBO = dataBO;
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSAttributedString *attriString = getLineSpaceAttributedString(dataBO.name,
[iphoneLineSpaceAndParaSpace returnLevel4LineSpace],
appFont(TEXT_THREE_LEVELSIZE, NO));
dispatch_async(dispatch_get_main_queue(), ^{
self.relateTextLabel.attributedText = attriString;
});
});
}
}
- (void)setLayoutSubviews {
[self.relateTextLabel makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.left).offset(contentPadding);
make.right.equalTo(self.right).offset(-contentPadding);
make.top.equalTo(self.top);
make.bottom.equalTo(self.bottom);
}];
[self.lineView makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.left).offset(contentPadding);
make.right.equalTo(self.right);
make.bottom.equalTo(self.bottom);
make.height.equalTo(@0.5);
}];
}
@end
|