tableview 自定义cell左边图片

来源:互联网 发布:淘宝链接转化微信 编辑:程序博客网 时间:2024/04/29 03:28
static NSString *cellIdentifier = @"cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
// Configure the cell...
if([self.dataArray count] == 0) {
return cell;
}
if(cell == nil) {
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
CGFloat x = 15.0f;
CGFloat image_width = 30.0f;
CGFloat y = (45.0f - image_width) /2.0f;
UIImageView *imageViews = [[UIImageView alloc] initWithFrame:CGRectMake(x, y, image_width, image_width)];
imageViews.tag = 1945;
imageViews.backgroundColor = [UIColor clearColor];
imageViews.layer.masksToBounds = YES;
imageViews.layer.cornerRadius = image_width / 2.0f;
[cell addSubview:imageViews];
// 文字缩进 (indentationLevel * indentationWidth)
cell.indentationLevel = 3;//缩进层级 默认0
cell.indentationWidth = (image_width + x) / 3.0f;//每次缩进寛 默认10
}
0 0
原创粉丝点击