|
//
// askFootMoreCell.m
// ThePaperDemo
//
// Created by scar1900 on 14-9-28.
// Copyright (c) 2014年 scar1900. All rights reserved.
//
#import "askFootMoreCell.h"
@interface askFootMoreCell()
@property(nonatomic, strong)UIView *backView;
@property(nonatomic, strong)UIButton *moreButton;
@property(nonatomic, strong)UIView *lineView1;
@property(nonatomic, strong)UIView *lineView2;
@property(nonatomic, strong)UIView *lineView3;
@property(nonatomic, strong)UIView *footView;
@end
@implementation askFootMoreCell
@synthesize commentBO;
@synthesize delegate;
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
self.selectionStyle = UITableViewCellSelectionStyleNone;
self.backgroundColor = [UIColor colorWithHexString:CELLBACKCOLOR];
[self addSubview:self.backView];
[self.backView addSubview:self.moreButton];
[self.backView addSubview:self.lineView1];
[self.backView addSubview:self.lineView2];
[self.backView addSubview:self.lineView3];
[self addSubview:self.footView];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(needrefreshNightMode:) name:REFRESHAFTERNIGHTMODE object:nil];
}
return self;
}
- (void)needrefreshNightMode:(id)sender{
self.backgroundColor = [UIColor colorWithHexString:CELLBACKCOLOR];
_moreButton.backgroundColor = [UIColor colorWithHexString:BackGroundColor];
_backView.backgroundColor = [UIColor colorWithHexString:BackGroundColor];
_lineView1.backgroundColor = [UIColor colorWithHexString:LINECOLOR];
_lineView2.backgroundColor = [UIColor colorWithHexString:LINECOLOR];
_lineView3.backgroundColor = [UIColor colorWithHexString:LINECOLOR];
_footView.backgroundColor = [UIColor colorWithHexString:CELLBACKCOLOR];
}
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (UIView*)backView {
if (!_backView) {
_backView = [[UIView alloc]initWithFrame:CGRectZero];
_backView.backgroundColor = [UIColor colorWithHexString:BackGroundColor];
}
return _backView;
}
- (UIButton*)moreButton {
if (!_moreButton) {
_moreButton = [UIButton buttonWithType:UIButtonTypeCustom];
_moreButton.backgroundColor = [UIColor colorWithHexString:BackGroundColor];
[_moreButton setTitle:@"查看更多回答" forState:UIControlStateNormal];
[_moreButton setTitleColor:[UIColor colorWithHexString:BLUECOLOR] forState:UIControlStateNormal];
[_moreButton setTitleColor:[UIColor colorWithHexString:TextGray] forState:UIControlStateHighlighted];
[_moreButton addTarget:self action:@selector(checkMoreAnswer) forControlEvents:UIControlEventTouchUpInside];
}
_moreButton.titleLabel.font = appFont(13, NO);
return _moreButton;
}
- (UIView*)lineView1 {
if (!_lineView1) {
_lineView1 = [[UIView alloc]initWithFrame:CGRectZero];
_lineView1.backgroundColor = [UIColor colorWithHexString:LINECOLOR];
}
return _lineView1;
}
- (UIView*)lineView2 {
if (!_lineView2) {
_lineView2 = [[UIView alloc]initWithFrame:CGRectZero];
_lineView2.backgroundColor = [UIColor colorWithHexString:LINECOLOR];
}
return _lineView2;
}
- (UIView*)lineView3 {
if (!_lineView3) {
_lineView3 = [[UIView alloc]initWithFrame:CGRectZero];
_lineView3.backgroundColor = [UIColor colorWithHexString:LINECOLOR];
}
return _lineView3;
}
- (UIView*)footView {
if (!_footView) {
_footView = [[UIView alloc]initWithFrame:CGRectZero];
_footView.backgroundColor = [UIColor colorWithHexString:CELLBACKCOLOR];
}
return _footView;
}
- (void)checkMoreAnswer {
if ([self.delegate respondsToSelector:@selector(clickAskMoreButton:)]) {
[self.delegate clickAskMoreButton:self.commentBO];
}
}
- (void)layoutSubviews {
self.backView.frame =CGRectMake(10, 0, CGRectGetWidth(self.bounds)-20, 65/2);
self.moreButton.frame = CGRectMake(0, 0, CGRectGetWidth(self.backView.bounds), 25);
self.lineView3.frame =CGRectMake(0, CGRectGetHeight(self.backView.bounds)-1, CGRectGetWidth(self.backView.bounds), 1);
self.lineView2.frame =CGRectMake(0, CGRectGetHeight(self.backView.bounds)-3, CGRectGetWidth(self.backView.bounds), 1);
self.lineView1.frame =CGRectMake(0, CGRectGetHeight(self.backView.bounds)-5, CGRectGetWidth(self.backView.bounds), 1);
self.footView.frame = CGRectMake(0, CGRectGetMaxY(self.backView.frame), CGRectGetWidth(self.bounds), 10);
[self.moreButton setTitleEdgeInsets:UIEdgeInsetsMake(6, 20, 6, 20)];
[super layoutSubviews];
}
@end
|