123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- //
- // WD_DetailCell.m
- // LNManager
- //
- // Created by EchoShacolee on 2017/6/6.
- // Copyright © 2017年 lee. All rights reserved.
- //
- #import "WD_DetailCell.h"
- #import "NSString+ex.h"
- @interface WD_DetailCell ()
- {
- UIView * _whiteV;
- UILabel * _titleLab;
- UILabel * _contentLab;
- UILabel * _timeLab;
- }
- @end
- @implementation WD_DetailCell
- - (void)awakeFromNib {
- [super awakeFromNib];
- // Initialization code
- }
- - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
- [super setSelected:selected animated:animated];
- // Configure the view for the selected state
- }
- +(WD_DetailCell *)cellForTableView:(UITableView *)tableView{
-
- WD_DetailCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cellId"];
- if (!cell) {
- // cell = [[[NSBundle mainBundle]loadNibNamed:@"WD_DetailCell" owner:nil options:nil]lastObject];
- cell = [[WD_DetailCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cellId"];
- }
- return cell;
- }
- -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
-
- self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
- if (self) {
- self.contentView.backgroundColor = KBackGroundColor;
-
- _whiteV = [UIView new];
- _whiteV.backgroundColor = [UIColor whiteColor];
- [self.contentView addSubview:_whiteV];
-
- _titleLab = [[UILabel alloc]init];
- _titleLab.font = [UIFont systemFontOfSize:17];
- _titleLab.numberOfLines = 0;
- [_whiteV addSubview:_titleLab];
-
- _contentLab = [[UILabel alloc]init];
- _contentLab.font = [UIFont systemFontOfSize:14];
- _contentLab.numberOfLines = 0;
- _contentLab.textColor = [UIColor darkGrayColor];
- [_whiteV addSubview:_contentLab];
-
- _timeLab = [[UILabel alloc]init];
- _timeLab.font = [UIFont systemFontOfSize:13];
- _timeLab.textAlignment = NSTextAlignmentCenter;
- // _timeLab.backgroundColor = KBackGroundColor;
- _timeLab.textColor = [UIColor lightGrayColor];
- [self.contentView addSubview:_timeLab];
- }
- return self;
- }
- -(void)setDic:(NSDictionary *)dic{
-
- if (_dic != dic) {
- _titleLab.text = dic[@"MI_TITLE"];
- _contentLab.text = dic[@"MI_CONTENT"];
- _timeLab.text = dic[@"MI_CRDATE"];
- }
- }
- -(void)layoutSubviews{
-
- CGFloat wid = self.width;
- CGFloat x,y,w,h,bd;
-
- x = 10;
- y = 0;
- w = wid - 40 - 20;
- bd = 5;
- h = [_titleLab.text heightForWid:w Font:17];
- _titleLab.frame = setDIYFrame;
-
- y += h+bd;
- h = [_contentLab.text heightForWid:w Font:14];
- _contentLab.frame = setDIYFrame;
-
- h = y+h+bd;
- y = 10;
- w = wid-20;
- _whiteV.frame = setDIYFrame;
-
- y += h+bd;
- h = 21;
- w = [_timeLab.text sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:13]}].width+10;
- _timeLab.frame = setDIYFrame;
- _timeLab.center = CGPointMake(self.center.x, y+h/2);
- }
- @end
|