|
//
// taskCell.m
// ThePaperBase
//
// Created by Huixin on 15/10/26.
// Copyright © 2015年 scar1900. All rights reserved.
//
#import "taskCell.h"
@interface taskCell()
@property(nonatomic, strong)UILabel *titleLabel;
@property(nonatomic, strong)UILabel *seashellLabel;
@property(nonatomic, strong)UIView *line;
@end
@implementation taskCell
- (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.titleLabel];
[self addSubview:self.seashellLabel];
[self layoutViews];
}
return self;
}
- (void)layoutViews {
[self.titleLabel makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.top).offset(20);
make.left.equalTo(self.left).offset(10);
make.height.mas_equalTo(@17);
make.width.mas_equalTo(rect_screen.size.width*0.7);
}];
[self.seashellLabel makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.titleLabel.right);
make.right.equalTo(self.right).offset(-10);
make.bottom.equalTo(self.titleLabel.bottom);
make.height.mas_equalTo(@15);
}];
}
- (UILabel*)titleLabel {
if (!_titleLabel) {
_titleLabel = [UILabel new];
_titleLabel.backgroundColor = [UIColor clearColor];
_titleLabel.textColor = [UIColor colorWithHexString:TextBlack];
_titleLabel.font = appFont(TEXT_FOUR_LEVELSIZE, NO);
}
return _titleLabel;
}
- (UILabel*)seashellLabel {
if (!_seashellLabel) {
_seashellLabel = [UILabel new];
_seashellLabel.backgroundColor = [UIColor clearColor];
_seashellLabel.textColor = [UIColor colorWithHexString:TextLightGray];
_seashellLabel.font = appFont(TEXT_FIVE_LEVELSIZE, NO);
_seashellLabel.textAlignment = NSTextAlignmentRight;
}
return _seashellLabel;
}
- (UIView*)line {
if (!_line) {
_line = [UIView new];
_line.backgroundColor = [UIColor colorWithHexString:LINECOLOR];
}
return _line;
}
- (void)addBottomLine {
[self addSubview:self.line];
[self.line makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.left).offset(10);
make.right.equalTo(self.right).offset(-10);
make.bottom.equalTo(self.bottom);
make.height.mas_equalTo(@0.5);
}];
}
- (void)setTaskInfo:(NSDictionary *)taskInfo {
self.titleLabel.text = taskInfo[@"title"];
self.seashellLabel.text = [NSString stringWithFormat:@"%@/%@", taskInfo[@"curSeashells"], taskInfo[@"maxSeashells"]];
}
- (void)awakeFromNib {
// Initialization code
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end
|