|
//
// hotAskContentCell.m
// ThePaperDemo
//
// Created by scar1900 on 14/10/30.
// Copyright (c) 2014年 scar1900. All rights reserved.
//
#import "hotAskContentCell.h"
@interface hotAskContentCell()
@property(nonatomic, strong)UIView *cellheadView;
@property(nonatomic, strong)UILabel *cellHeadLabel;
@end
@implementation hotAskContentCell
@synthesize commentBO = _commentBO;
@synthesize delegate;
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
[self.backView addSubview:self.cellheadView];
[self.cellheadView addSubview:self.cellHeadLabel];
}
return self;
}
- (void)setCommentBO:(commentObjectVO *)data {
_commentBO = data;
self.askAuthorLabel.text = data.userName?[NSString stringWithFormat:@"%@:",data.userName]:@"";
self.anserNumsLabel.text = data.answerNums?[NSString stringWithFormat:@"(%@个回答)",data.answerNums]:@"";
self.askContentLabel.text = data.content?data.content:@"";
self.cellHeadLabel.text = data.contName?data.contName:@"";
}
- (UIView *)cellheadView {
if (!_cellheadView) {
_cellheadView = [[UIView alloc]initWithFrame:CGRectZero];
_cellheadView.backgroundColor = [UIColor colorWithHexString:CELLBACKCOLOR];
UIButton *labelBack = [UIButton buttonWithType:UIButtonTypeCustom];
labelBack.tag = 100;
labelBack.backgroundColor = [UIColor whiteColor];
[labelBack addTarget:self action:@selector(headButtonClick:) forControlEvents:UIControlEventTouchUpInside];
[_cellheadView addSubview:labelBack];
UIView *cellHeadLine = [[UIView alloc]initWithFrame:CGRectZero];
cellHeadLine.backgroundColor = [UIColor colorWithHexString:LINECOLOR];
cellHeadLine.tag = 101;
[_cellheadView addSubview:cellHeadLine];
}
return _cellheadView;
}
- (UILabel*)cellHeadLabel {
if (!_cellHeadLabel) {
_cellHeadLabel = [[UILabel alloc]initWithFrame:CGRectZero];
_cellHeadLabel.textColor = [UIColor colorWithHexString:LIGHTGRAY];
_cellHeadLabel.textAlignment = NSTextAlignmentLeft;
_cellHeadLabel.backgroundColor = [UIColor clearColor];
_cellHeadLabel.numberOfLines = 1;
_cellHeadLabel.lineBreakMode = NSLineBreakByTruncatingTail;
}
_cellHeadLabel.font = appFont(11, NO);
return _cellHeadLabel;
}
- (void)layoutSubviews {
[super layoutSubviews];
self.backView.frame = CGRectMake(10, 0, CGRectGetWidth(self.bounds)-20, CGRectGetHeight(self.bounds));
self.cellheadView.frame = CGRectMake(0, 0, CGRectGetWidth(self.backView.bounds), 30);
self.cellHeadLabel.frame = CGRectMake(15/2, 10,CGRectGetWidth(self.cellheadView.bounds)-15/2 , 19);
UIButton *labelBack = (UIButton*)[self.cellheadView viewWithTag:100];
labelBack.frame = CGRectMake(0, 10, CGRectGetWidth(self.cellheadView.bounds), 20);
UIView *cellHeadLine = [self.cellheadView viewWithTag:101];
cellHeadLine.frame = CGRectMake(0, CGRectGetHeight(self.cellheadView.bounds)-1, CGRectGetWidth(self.cellheadView.bounds), 1);
self.askAuthorLabel.frame = CGRectMake(15/2, CGRectGetMaxY(self.cellheadView.frame), CGRectGetWidth(self.backView.bounds)/2-15/2, 25);
self.anserNumsLabel.hidden = YES;
self.askContentLabel.frame = CGRectMake(CGRectGetMinX(self.askAuthorLabel.frame), CGRectGetMaxY(self.askAuthorLabel.frame), 285, CGRectGetHeight(self.backView.bounds)-25);
}
- (void)headButtonClick:(UIButton*)btn {
if ([self.delegate respondsToSelector:@selector(titleClick:)]) {
[self.delegate titleClick:self.commentBO];
}
}
@end
|