|
//
// trackHeadCell.m
// ThePaperHD
//
// Created by scar1900 on 15/3/31.
// Copyright (c) 2015年 scar1900. All rights reserved.
//
#import "trackHeadCell.h"
@interface trackHeadCell() {
CGFloat titleWidth;
}
@property(nonatomic, strong)UIView *backView;
@property(nonatomic, strong)UILabel *titleLabel;
@property(nonatomic, strong)UIImageView *expandImageView;
@property(nonatomic, strong)UILabel *markLabel;
@end
@implementation trackHeadCell
@synthesize trackerInfoBO = _trackerInfoBO;
- (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.backView];
[self.backView addSubview:self.titleLabel];
[self.backView addSubview:self.expandImageView];
[self.backView addSubview:self.markLabel];
}
return self;
}
- (void)setTrackerInfoBO:(trackerInfoBO *)data {
_trackerInfoBO = data;
self.titleLabel.text = data.tags;
titleWidth = widthForString(data.tags, self.titleLabel.font, CGRectGetHeight(self.backView.bounds), self.titleLabel.lineBreakMode);
if ([data.isOpen intValue] == 1) {
self.expandImageView.image = Image(@"setting/trackExpanded.png");
}else {
self.expandImageView.image = Image(@"setting/trackExpand.png");
}
if ([data.unNum intValue] > 0) {
self.markLabel.hidden = NO;
self.markLabel.text = data.unNum;
}else {
self.markLabel.hidden = YES;
}
}
- (UIView*)backView {
if (!_backView) {
_backView = [[UIView alloc]initWithFrame:CGRectZero];
_backView.backgroundColor = [UIColor colorWithHexString:CELLBACKCOLOR];
_backView.autoresizingMask = UIViewAutoresizingFlexibleRightMargin;
}
return _backView;
}
- (UILabel*)titleLabel {
if (!_titleLabel) {
_titleLabel = [[UILabel alloc]initWithFrame:CGRectZero];
_titleLabel.font = appFont(25, NO);
_titleLabel.textColor = [UIColor colorWithHexString:TextBlack];
_titleLabel.textAlignment = NSTextAlignmentLeft;
_titleLabel.lineBreakMode = NSLineBreakByTruncatingTail;
_titleLabel.backgroundColor = [UIColor clearColor];
}
return _titleLabel;
}
- (UIImageView*)expandImageView {
if (!_expandImageView) {
_expandImageView = [[UIImageView alloc]initWithFrame:CGRectZero];
}
return _expandImageView;
}
- (UILabel*)markLabel {
if (!_markLabel) {
_markLabel = [[UILabel alloc]initWithFrame:CGRectZero];
_markLabel.backgroundColor = [UIColor colorWithHexString:@"0xc32128"];
_markLabel.layer.cornerRadius = 11/2;
_markLabel.clipsToBounds = YES;
_markLabel.textAlignment = NSTextAlignmentCenter;
_markLabel.textColor = [UIColor whiteColor];
_markLabel.font = appFont(7, NO);
_markLabel.hidden = YES;
}
return _markLabel;
}
- (void)layoutSubviews {
[super layoutSubviews];
if (self.isEditing) {
[self sendSubviewToBack:self.contentView];
}
self.backView.frame = CGRectMake(15, 5, CGRectGetWidth(self.bounds)-30, CGRectGetHeight(self.bounds)-5);
self.titleLabel.frame = CGRectMake(12, 0, CGRectGetWidth(self.backView.bounds)-12-30, CGRectGetHeight(self.backView.bounds));
self.expandImageView.frame = CGRectMake(CGRectGetWidth(self.backView.bounds)-25, CGRectGetHeight(self.backView.bounds)/2-15/4, 13, 15/2);
self.markLabel.frame = CGRectMake(CGRectGetMinX(self.titleLabel.frame)+titleWidth, 8, 11, 11);
}
- (void)awakeFromNib {
// Initialization code
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end
|