//
// channelListBannerCell.m
// ThePaperBase
//
// Created by scar1900 on 15/8/21.
// Copyright (c) 2015年 scar1900. All rights reserved.
//
#import "channelListBannerCell.h"
@implementation channelListBannerCell
@synthesize imageScale;
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
self.contentView.backgroundColor = [UIColor colorWithHexString:CELLBACKCOLOR];
[self.contentView makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self);
}];
self.isTopic = NO;
self.selectionStyle = UITableViewCellSelectionStyleNone;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(needrefreshNightMode:) name:REFRESHAFTERNIGHTMODE object:nil];
}
return self;
}
- (void)layoutSubviews {
CGFloat cellHeight = CGRectGetHeight(self.contentView.bounds);
if (cellHeight == 0) {
self.bannerView.hidden = YES;
}else {
self.bannerView.hidden = NO;
}
CGFloat imageHeight = (rect_screen.size.width-20)*imageScale;
if (self.isTopic) {
[self.bannerView remakeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.contentView.left).equalTo(10);
make.right.equalTo(self.contentView.right).equalTo(-10);
make.bottom.equalTo(self.contentView.bottom).offset(-5);
make.height.mas_equalTo(imageHeight);
}];
}else {
[self.bannerView remakeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.contentView.left).equalTo(10);
make.right.equalTo(self.contentView.right).equalTo(-10);
make.bottom.equalTo(self.contentView.bottom);
make.height.mas_equalTo(imageHeight);
}];
}
}
- (void)needrefreshNightMode:(id)sender{
self.contentView.backgroundColor = [UIColor colorWithHexString:CELLBACKCOLOR];
}
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
@end
|