123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- //
- // FavCell.m
- // jiaPei
- //
- // Created by apple on 15/12/12.
- // Copyright © 2015年 JCZ. All rights reserved.
- //
- #import "FavCell.h"
- @interface FavCell()
- /**用于显示驾考圈3字。取代detailLabel的。
- */
- @property (nonatomic,strong) UILabel *lblTag;
- @property (nonatomic,strong) UILabel *nameLabel;
- @end
- @implementation FavCell
- - (void)awakeFromNib {
- // Initialization code
- [super awakeFromNib];
- }
- - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
- [super setSelected:selected animated:animated];
- }
- +(FavCell*)cellForTableView:(UITableView*)tableView
- {
- FavCell* cell = [tableView dequeueReusableCellWithIdentifier:@"FavCell"];
- if (!cell) {
- cell = [[FavCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"FavCell"];
-
- [cell.textLabel setTextColor:kTitleColor];
- [cell.textLabel setFont:[UIFont scaleSize:15]];
- [cell.textLabel setNumberOfLines:0];
-
- UILabel *label = [UILabel new];
- [cell addSubview:label];
- cell.lblTag = label;
- [cell.lblTag setFont:[UIFont scaleSize:13]];
- [cell.lblTag setTextAlignment:NSTextAlignmentCenter];
- [cell.lblTag setBackgroundColor:defGreen];
- [cell.lblTag setTextColor:[UIColor whiteColor]];
- [cell.lblTag borderColor:defGreen width:.01 cornorRadios:3];
-
- label = [UILabel new];
- [cell addSubview:label];
- cell.nameLabel = label;
- [cell.nameLabel setTextColor:kTitleColor];
- [cell.nameLabel setFont:[UIFont scaleSize:17]];
- }
- return cell;
- }
- -(void)setModel:(NSDictionary *)model
- {
- _model = model;
- [self.textLabel setText:model[@"CONTENT"]];
- [self.lblTag setText:model[@"GROUPNAME"]];
- if ([model[@"GROUPNAME"] isEqualToString:@""])
- {
- [self.lblTag setText:@"社区"];
- }
-
- self.nameLabel.text = model[@"NAME"];
- }
- /**上,下,左右。内间距。都是20
- */
- -(void)layoutSubviews
- {
- [super layoutSubviews];
- CGFloat x,y,w,h,bd;
- bd = 20;
-
- x = bd;
- y = 10;
- w = 200;
- h = 20;
- [self.nameLabel setFrame:CGRectMake(x, y, w, h)];
-
- y += 10 + h;
- w = kSize.width - bd*2;
- h = [self.textLabel.text heightForWid:w Font:15];
- [self.textLabel setFrame:CGRectMake(x, y, w, h)];
-
- y += h +bd;
- w = [self.lblTag.text sizeForFont:13].width + 15;
- h = [self.lblTag.text sizeForFont:13].height + 10;
- [self.lblTag setFrame:CGRectMake(x, y, w, h)];
- // w = [self.detailTextLabel.text sizeForFont:13].width + 15;
- // h = [self.detailTextLabel.text sizeForFont:13].height + 10;
- // [self.detailTextLabel setFrame:CGRectMake(x, y, w, h)];
- }
- @end
- CGFloat FavCellHeightByDict(NSDictionary* dict)
- {
- if (!dict) {
- return .1;
- }
-
- CGFloat w,h,bd;
- bd = 20;
- w = kSize.width - bd*2;
-
- h = [dict[@"CONTENT"] heightForWid:w Font:15] + bd;
- h += [@"驾考" sizeForFont:13].height + 40 + bd;
- return h;
- }
|