// // liveContFootCell.m // ThePaperHD // // Created by scar1900 on 15/3/11. // Copyright (c) 2015年 scar1900. All rights reserved. // #import "liveContFootCell.h" #define CONTENTWIDTH 1060/2 @interface liveContFootCell() @property(nonatomic, strong)UIButton *askMoreBtn; @property(nonatomic, strong)UIView *bottomLine; @property(nonatomic, strong)UIView *lineView; @property(nonatomic, strong)UILabel *shareLabel; @property(nonatomic, strong)UIButton *shareBtn; @end @implementation liveContFootCell @synthesize dataDic = _dataDic; @synthesize delegate; @synthesize indexPath; @synthesize isLast; - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { self.backgroundColor = [UIColor colorWithHexString:BackGroundColor]; self.selectionStyle = UITableViewCellSelectionStyleNone; [self.contentView addSubview:self.askMoreBtn]; [self.contentView addSubview:self.bottomLine]; [self.contentView addSubview:self.lineView]; [self.contentView addSubview:self.shareLabel]; [self.contentView addSubview:self.shareBtn]; self.isLast = NO; } return self; } - (void)setDataDic:(NSDictionary *)dic { _dataDic = dic; if ([dic.allKeys containsObject:@"strongRelate"]) { [self.askMoreBtn setHidden:NO]; }else { [self.askMoreBtn setHidden:YES]; } NSString *type = dic[@"type"]; if ([type isMatchedByRegex:@"top"]) { self.lineView.hidden = YES; }else self.lineView.hidden = NO; } - (UIButton*)askMoreBtn { if (!_askMoreBtn) { _askMoreBtn = [UIButton buttonWithType:UIButtonTypeCustom]; [_askMoreBtn setTitle:@"点击查看详情" forState:UIControlStateNormal]; [_askMoreBtn setTitleColor:[UIColor colorWithHexString:BLUECOLOR] forState:UIControlStateNormal]; [_askMoreBtn setTitleColor:[UIColor colorWithHexString:BUTTONSELECTBACK] forState:UIControlStateHighlighted]; _askMoreBtn.titleLabel.font = appFont(15, NO); _askMoreBtn.titleLabel.textAlignment = NSTextAlignmentCenter; // askMoreHanlder [_askMoreBtn addTarget:self action:@selector(askMoreHanlder:) forControlEvents:UIControlEventTouchUpInside]; } return _askMoreBtn; } - (UIView*)lineView { if (!_lineView) { _lineView = [[UIView alloc]initWithFrame:CGRectZero]; _lineView.backgroundColor = [UIColor colorWithHexString:LINECOLOR]; } return _lineView; } - (UIView*)bottomLine { if (!_bottomLine) { _bottomLine = [[UIView alloc]initWithFrame:CGRectZero]; _bottomLine.backgroundColor = [UIColor colorWithHexString:LINECOLOR]; } return _bottomLine; } - (UILabel*)shareLabel { if (!_shareLabel) { _shareLabel = [[UILabel alloc]initWithFrame:CGRectZero]; _shareLabel.text = @"分享到"; _shareLabel.font = appFont(15, NO); _shareLabel.textColor = [UIColor colorWithHexString:TextGray]; _shareLabel.textAlignment = NSTextAlignmentCenter; _shareLabel.backgroundColor = [UIColor clearColor]; } return _shareLabel; } - (UIButton*)shareBtn { if (!_shareBtn) { _shareBtn = [UIButton buttonWithType:UIButtonTypeCustom]; [_shareBtn setImage:Image(@"Button/liveShareBtn.png") forState:UIControlStateNormal]; [_shareBtn addTarget:self action:@selector(shareHandler:) forControlEvents:UIControlEventTouchUpInside]; } return _shareBtn; } - (void)askMoreHanlder:(UIButton*)btn { if ([self.delegate respondsToSelector:@selector(goToDetailPage:)]) { [self.delegate goToDetailPage:self.dataDic[@"strongRelate"]]; } } - (void)shareHandler:(UIButton*)btn { NSString* shareText = self.dataDic[@"title"]; if ([self.delegate respondsToSelector:@selector(shareEvent:indexPath:offset:)]) { [self.delegate shareEvent:shareText indexPath:self.indexPath offset:CGRectGetMinX(self.shareBtn.frame)]; } } - (void)layoutSubviews { CGFloat padding = 0; UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation]; if (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight) { padding = 125; } self.askMoreBtn.frame = CGRectMake(padding+226/2, 0, 192/2, 26); self.shareLabel.frame = CGRectMake(CGRectGetMaxX(self.askMoreBtn.frame)+696/2, CGRectGetMinY(self.askMoreBtn.frame), 50, CGRectGetHeight(self.askMoreBtn.frame)); self.bottomLine.frame = CGRectMake(padding+226/2, 33, CONTENTWIDTH, 1); self.shareBtn.frame = CGRectMake(CGRectGetMaxX(self.shareLabel.frame)+8, 0, 30, 30); if (self.isLast) { self.lineView.frame = CGRectMake(padding+7, 0, 1, 33); }else { self.lineView.frame = CGRectMake(padding+7, 0, 1, CGRectGetHeight(self.bounds)); } [super layoutSubviews]; } - (void)awakeFromNib { // Initialization code } - (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; // Configure the view for the selected state } @end