/** 自定义cell。图标大小合适,可控。 总体和普通cell没区别 */ #import "CLCell.h" @implementation CLCell - (void)awakeFromNib { [super awakeFromNib]; } - (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; } -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { _headerImg = [[UIImageView alloc] init]; [self.contentView addSubview:_headerImg]; } return self; } +(CLCell*)cellForTableView:(UITableView*)tableView Style:(UITableViewCellStyle)style { CLCell* cell = [tableView dequeueReusableCellWithIdentifier:@"CLCell"]; if (!cell) { cell = [[CLCell alloc] initWithStyle:style reuseIdentifier:@"CLCell"]; } return cell; } +(CGFloat)cellHeight { return 40; } -(void)layoutSubviews { [super layoutSubviews]; CGFloat hei = self.frame.size.height; CGFloat wid = self.frame.size.width; CGFloat len = hei*.65; // CGFloat x,y,w,h; if (_leftBd < .1) { _leftBd = 20; } self.imageView.frame = CGRectMake( hei - len + 1, (hei - len)/2 + 1, len - 2, len - 2); if (self.imageView.image) { self.textLabel.frame = CGRectMake( hei+hei - len, 0, wid- (hei+hei - len)-10, hei); }else{ self.textLabel.frame = CGRectMake( 0, 0, wid, hei); } _headerImg.frame = CGRectMake(wid - hei - 40, 2, hei - 4, hei - 4); [_headerImg setRound]; } @end