|
//
// hotAskContentInListCell.m
// ThePaperHD
//
// Created by scar1900 on 15/3/17.
// Copyright (c) 2015年 scar1900. All rights reserved.
//
#import "hotAskContentInListCell.h"
@interface hotAskContentInListCell()
@property(nonatomic, strong)UIButton *focusButton;
@end
@implementation hotAskContentInListCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
self.backgroundColor = [UIColor clearColor];
self.selectionStyle = UITableViewCellSelectionStyleNone;
self.clipsToBounds = YES;
[self addSubview:self.focusButton];
}
return self;
}
- (UIButton*)focusButton {
if (!_focusButton) {
_focusButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_focusButton setTitle:@"关注" forState:UIControlStateNormal];
[_focusButton setTitle:@"已关注" forState:UIControlStateSelected];
[_focusButton setTitleColor:[UIColor colorWithHexString:LIGHTGRAY] forState:UIControlStateNormal];
_focusButton.titleLabel.font = appFont(11, NO);
_focusButton.layer.borderColor = [UIColor colorWithHexString:LIGHTGRAY].CGColor;
_focusButton.layer.borderWidth = 1;
_focusButton.layer.cornerRadius = 2;
[_focusButton addTarget:self action:@selector(focusHandler:) forControlEvents:UIControlEventTouchUpInside];
}
return _focusButton;
}
- (void)focusHandler:(UIButton*)btn {
if ([self.hotAskDelegate respondsToSelector:@selector(focusAsk:isToFocus:button:)]) {
[self.hotAskDelegate focusAsk:self.commentBO isToFocus:!btn.selected button:btn];
}
}
- (void)layoutSubviews {
[super layoutSubviews];
self.focusButton.frame = CGRectMake(CGRectGetMinX(self.answerNumLabel.frame)-70,
CGRectGetMinY(self.answerNumLabel.frame)-5,
60,
30);
self.menuButton.frame = CGRectMake(CGRectGetMinX(self.askNameLabel.frame), CGRectGetMaxY(self.askNameButton.frame)+5, CGRectGetWidth(self.bounds)-CGRectGetMinX(self.askNameLabel.frame)-10, CGRectGetHeight(self.bounds)-CGRectGetMaxY(self.askNameButton.frame)-5);
if ([TPUserDefault instance].userBO && [self.commentBO.isAttented intValue] == 1) {
self.focusButton.selected = YES;
}else {
self.focusButton.selected = NO;
}
}
@end
|