ios 自定义tableViewcell,UITableViewCell

//自定义tableViewcell,当系统自带的tableView样式无法满足我们的需求可通过代码实现自定义cell

demo效果看附件

#import <UIKit/UIKit.h>

#import "Houses.h"

#define kRowWidth [UIScreen mainScreen].bounds.size.width

#define kRowHeight 90

@interface HouseTableViewCell :UITableViewCell

– (void)setHouses:(Houses *)houses;

@end

#import "HouseTableViewCell.h"

@interfaceHouseTableViewCell ()

{

UIImageView * _imageView;

UILabel * _titleLabel;

UILabel * _subLabel;

UILabel * _skimNums;

}

@end

@implementation HouseTableViewCell

– (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{

self = [superinitWithStyle:style reuseIdentifier:reuseIdentifier];

if (self) {

[self_addSubviews];

}

returnself;

}

#pragma mark – _addSubviews

– (void)_addSubviews{

// 1.添加图片_imageView

alloc]initWithFrame:CGRectMake(5,,

[selfaddSubview

// 2.添加标题_titleLabel

UILabelframe.origin.x *frameframe.origin.y,kRowWidth – – _imageView.frame.size.width ,45)];

boldSystemFontOfSize

textColor = [UIColorgrayColor];

_titleLabel];

// 3.添加副标题_subLabel

UILabelframe.origin.x *frame,kRowWidth – – _imageView.frame.size.width ,35)];

[selfaddSubview:_subLabel];

boldSystemFontOfSize

textColor = [UIColorgrayColor];

numberOfLines =0;

// _subLabel.adjustsFontSizeToFitWidth =YES;

// 4.添加浏览量_skimNums

alloc -,

adjustsFontSizeToFitWidth

[selfaddSubview

}

#pragma setHouses:(Houses *)houses

– (void)setHouses:(Houses *)houses{//新建一个类houses,用来存数数据

NSString * imgPath = houses.imgPath;

UIImage * image = [UIImageimageNamed:imgPath];

_imageView.image = image;

titleLabel ;

subLabel;

,houses.skimNums];

}

– (void)awakeFromNib {

// Initialization code

}

– (void)setSelected:(BOOL)selected animated:(BOOL)animated {

[supersetSelected:selected animated:animated];

// Configure the view for the selected state

}

@end

//自定义tableViewcell,当系统自带的tableView样式无法满足我们的需求可通过代码实现自定义cell

//自定义tableViewcell,当系统自带的tableView样式无法满足我们的需求可通过代码实现自定义cell

//自定义tableViewcell,当系统自带的tableView样式无法满足我们的需求可通过代码实现自定义cell

//自定义tableViewcell,当系统自带的tableView样式无法满足我们的需求可通过代码实现自定义cell

//自定义tableViewcell,当系统自带的tableView样式无法满足我们的需求可通过代码实现自定义cell

//自定义tableViewcell,当系统自带的tableView样式无法满足我们的需求可通过代码实现自定义cell

//自定义tableViewcell,,当系统自带的tableView样式无法满足我们的需求可通过代码实现自定义cell

//自定义tableViewcell,当系统自带的tableView样式无法满足我们的需求可通过代码实现自定义cell

//自定义tableViewcell,当系统自带的tableView样式无法满足我们的需求可通过代码实现自定义cell

//自定义tableViewcell,当系统自带的tableView样式无法满足我们的需求可通过代码实现自定义cell

//自定义tableViewcell,当系统自带的tableView样式无法满足我们的需求可通过代码实现自定义cell

那些无法讲述的悲伤和苍凉,

ios 自定义tableViewcell,UITableViewCell

相关文章:

你感兴趣的文章:

标签云: