123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- #import "STCell.h"
- @implementation STCell
- - (void)awakeFromNib {
- [super awakeFromNib];
- // Initialization code
- }
- - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
- [super setSelected:selected animated:animated];
- }
- +(STCell*)cellForTableView:(UITableView*)tableView
- {
- STCell* cell = [tableView dequeueReusableCellWithIdentifier:@"STCell"];
- if (!cell) {
- cell = [[STCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"STCell"];
-
- [cell.textLabel setTextColor:subTitleColor];
- [cell.detailTextLabel setTextColor:contentTextColor];
- }
- return cell;
- }
- //消息
- -(void)setModel:(NSDictionary *)model
- {
- _model = model;
- NSString *path = model[@"PHOTO"];
- if (path && ![path hasPrefix:@"http"]){
- path = [imgPreFix stringByAppendingString:path];
- }
-
- [self.imageView sd_setImageWithURL: [NSURL URLWithString: path] placeholderImage:randomPortrait()];
- [self.textLabel setText:model[@"CONTENT"]];
- [self.textLabel setFont:[UIFont scaleSize:18]];
- [self.textLabel setNumberOfLines:0];
- [self.detailTextLabel setText:model[@"CRDATE"]];
- [self.detailTextLabel setTextAlignment:NSTextAlignmentRight];
- }
- //点赞评论
- -(void)setModelReply:(NSDictionary *)model
- {
- _modelReply = model;
-
- NSString *path = model[@"HEADIMG"];
- if (path && ![path hasPrefix:@"http"]){
- path = [imgPreFix stringByAppendingString:path];
- }
- [self.imageView sd_setImageWithURL: [NSURL URLWithString: path] placeholderImage:randomPortrait()];
-
- int type = [model[@"TYPE"] intValue];
- if (2 == type) {
- [self.textLabel setText:[model[@"NAME"] stringByAppendingString:@"赞了您的话题"] ];
- }else if (1 == type){
- [self.textLabel setText:[model[@"NAME"] stringByAppendingString:@"回复了您的评论"] ];
- }else{
- [self.textLabel setText:[model[@"NAME"] stringByAppendingString:@"评论了您的话题"] ];
- }
- [self.detailTextLabel setText:model[@"CRDATE"]];
- }
- -(void)layoutSubviews
- {
- [super layoutSubviews];
- CGFloat wid = self.width;
- CGFloat hei = self.height;
- CGFloat x,y,w,h;
- if (_model)
- {
- x = 27;
- y = 15;
- w = h = 43;
- [self.imageView setFrame:CGRectMake(x, y, w, h)];
- self.imageView.layer.masksToBounds = YES;
- self.imageView.layer.cornerRadius = self.imageView.height/2.0;
-
- x += w + 10;
- y = 10;
- w = wid - x - 20;
- h = hei - 40;
- [self.textLabel setFrame:CGRectMake(x, y, w, h)];
- [self.textLabel.layer setMasksToBounds:YES];
-
- x = wid - 180;
- w = 160;
- y = hei - 30;
- h = 21;
- [self.detailTextLabel setFrame:CGRectMake(x, y, w, h)];
- }
- if (_modelReply)
- {
- x = 30;
- y = hei*.2;
- w = h = hei - y*2;
- [self.imageView setFrame:CGRectMake(x, y, w, h)];
- self.imageView.layer.masksToBounds = YES;
- self.imageView.layer.cornerRadius = self.imageView.height/2.0;
-
- x += w + 10;
- w = wid - x;
- h = hei*.3;
- [self.textLabel setFrame:CGRectMake(x, y, w, h)];
- y = hei* .6;
- h = hei*.3;
- [self.detailTextLabel setFrame:CGRectMake(x, y, w, h)];
- }
- }
- @end
|