|
//
// channelTopicSearchCell.m
// ThePaperBase
//
// Created by YoungLee on 15/8/4.
// Copyright (c) 2015年 scar1900. All rights reserved.
//
#import "channelTopicSearchCell.h"
@interface channelTopicSearchCell()
@property(nonatomic, strong)UITextField *searchContent;
@property(nonatomic, strong)UILabel *searchPlaceHolder;
@property(nonatomic, strong)UILabel *searchLabel;
@property(nonatomic, strong)UIImageView *searchIcon;
@end
@implementation channelTopicSearchCell
- (void)awakeFromNib {
// Initialization code
}
-(instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier{
self = [super initWithReuseIdentifier:reuseIdentifier];
if (self) {
self.backgroundColor = [UIColor colorWithHexString:CELLBACKCOLOR];
[self.contentView addSubview:self.searchContent];
[self.contentView addSubview:self.searchLabel];
[self.contentView addSubview:self.searchPlaceHolder];
[self.contentView addSubview:self.searchIcon];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(needrefreshNightMode:) name:REFRESHAFTERNIGHTMODE object:nil];
}
return self;
}
- (void)needrefreshNightMode:(id)sender{
self.backgroundColor = [UIColor colorWithHexString:CELLBACKCOLOR];
self.searchLabel.textColor = [UIColor colorWithHexString:TextBlack];
self.searchContent.layer.borderColor = [UIColor colorWithHexString:LINECOLOR].CGColor;
self.searchContent.backgroundColor = [UIColor colorWithHexString:BackGroundColor];
}
- (void)dealloc {
[[NSNotificationCenter defaultCenter]removeObserver:self];
/**
* bug:5637(其他:app放置在后台一段时间,热启动,切换到夜间模式,即闪退)
*/
}
#pragma mark -- set view
-(UITextField *)searchContent{
if (!_searchContent) {
_searchContent = [[UITextField alloc] initWithFrame:CGRectZero];
_searchContent.layer.borderColor = [UIColor colorWithHexString:LINECOLOR].CGColor;
_searchContent.backgroundColor = [UIColor colorWithHexString:BackGroundColor];
_searchContent.layer.borderWidth = 1;
_searchContent.layer.cornerRadius = 5;
_searchContent.userInteractionEnabled = NO;
}
return _searchContent;
}
-(UILabel *)searchPlaceHolder{
if (!_searchPlaceHolder) {
_searchPlaceHolder = [[UILabel alloc]initWithFrame:CGRectZero];
_searchPlaceHolder.text = @"话题搜索";
_searchPlaceHolder.font = appFont(13, NO);
_searchPlaceHolder.textColor = [UIColor colorWithHexString:TextLightGray];
}
return _searchPlaceHolder;
}
-(UILabel *)searchLabel{
if (!_searchLabel) {
_searchLabel = [[UILabel alloc] initWithFrame:CGRectZero];
_searchLabel.font = appFont(TEXT_FOUR_LEVELSIZE, NO);
_searchLabel.textColor = [UIColor colorWithHexString:TextBlack];
_searchLabel.textAlignment = NSTextAlignmentCenter;
_searchLabel.text = @"搜索";
}
return _searchLabel;
}
-(UIImageView *)searchIcon{
if(!_searchIcon){
_searchIcon = [[UIImageView alloc] init];
_searchIcon.image = Image(@"setting/search_icon.png");
// _searchIcon.userInteractionEnabled = NO;
}
return _searchIcon;
}
-(void)layoutSubviews{
[self.searchContent makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.contentView.left).offset(10);
make.right.equalTo(self.contentView.right).offset(-50);
make.top.equalTo(self.contentView.top).offset(10);
make.height.equalTo(30);
}];
[self.searchLabel makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.searchContent.right);
make.right.equalTo(self.contentView.right);
make.top.equalTo(self.searchContent.top);
make.bottom.equalTo(self.searchContent.bottom);
}];
[self.searchIcon makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.searchContent.left).offset(9);
make.centerY.equalTo(self.contentView.centerY);
make.width.mas_equalTo(@11);
make.height.mas_equalTo(@12);
}];
// self.searchIcon.backgroundColor = [UIColor greenColor];
[self.searchPlaceHolder makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.searchIcon.right).offset(5);
make.right.equalTo(self.searchContent.right);
make.top.equalTo(self.searchContent.top);
make.bottom.equalTo(self.searchContent.bottom);
}];
[super layoutSubviews];
}
@end
|