123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- //
- // CommentCell.m
- // jiaPeiC
- //
- // Created by apple on 16/3/21.
- // Copyright © 2016年 JCZ. All rights reserved.
- //
- #import "CommentCell.h"
- #import "UIImageView+WebCache.h"
- @implementation CommentCell
- - (void)awakeFromNib {
- [super awakeFromNib];
- // Initialization code
- }
- -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
- {
- self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
- if (self) {
-
- UIImageView* iv = [[UIImageView alloc] init];
- iv.layer.masksToBounds = YES;
- iv.contentMode = UIViewContentModeCenter;
- [iv setContentMode:UIViewContentModeScaleAspectFit];
- [iv boardWid:1.5 Color:defGreen];
- [self.contentView addSubview:iv];
- headImg = iv;
-
- UILabel* lb;
- lb = [[UILabel alloc] init];
- [lb setTextColor:titleColor];
- [lb setFont:[UIFont scaleSize:Font16]];
- [self.contentView addSubview:lb];
- nameLabel = lb;
-
- lb = [[UILabel alloc] init];
- [lb setTextColor:contentTextColor];
- [lb setFont:[UIFont scaleSize:Font14]];
- lb.numberOfLines = 0;
- [self.contentView addSubview:lb];
- contentLabel = lb;
-
- lb = [[UILabel alloc] init];
- [lb setTextColor:contentTextColor];
- [lb setFont:[UIFont scaleSize:Font14]];
- [self.contentView addSubview:lb];
- dateLabel = lb;
- }
-
- [self setSelectionStyle:UITableViewCellSelectionStyleNone];
- return self;
- }
- -(void)setDict:(NSDictionary *)dict
- {
- _dict = dict;
-
- NSString *path = dict[@"HEADIMG"];
- if (!path) {
- path = @"";
- }
- [headImg sd_setImageWithURL:[NSURL URLWithString:path] placeholderImage:[UIImage imageNamed:[NSString stringWithFormat:@"portrait%d.png",arc4random()%10 + 1]]];
-
- [nameLabel setText:dict[@"NAME"]];
- [contentLabel setText:dict[@"PJCONTENT"]];
-
- NSString* str = dict[@"PJSJ"];
- if (str && str.length >11) {
- [dateLabel setText:[str substringToIndex:11]];
- }else{
- [dateLabel setText:str];
- }
- }
- -(void)layoutSubviews
- {
- [super layoutSubviews];
-
- CGFloat aWid = self.width;
- CGFloat x,w,h,y,bd;
- x = 8;
- w = h = 62;
- y = bd = 10;
- [headImg setFrame:CGRectMake(x, y, w, h)];
- headImg.layer.cornerRadius = h/2.0;
-
- y += bd;
- x += w + bd;
- h = 25;
- [nameLabel setFrame:CGRectMake(x, y, 200, h)];
-
- y = y+h;
- h = 25;
- [dateLabel setFrame:CGRectMake(x, y, 200, h)];
-
- y += h + bd;
- w = aWid - x - bd;
- h = [contentLabel.text heightForWid:w Font:Font14];
- if (h < 30.0)
- {
- h = 30;
- }
- [contentLabel setFrame:CGRectMake(x, y, w, h)];
-
- //固定高度90 最小高度120
- }
- - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
- [super setSelected:selected animated:animated];
- // Configure the view for the selected state
- }
- @end
|