iOS-UITableCell详情

iOS-UITableCell详情

表示UITableViewCell风格的常量有:

UITableViewCellStyleDefault

UITableViewCellStyleSubtitle

UITableViewCellStyleValue1

UITableViewCellStyleValue2

下面是各种式样的图片:
cell样式


系统自带cell的代码编写:

UITableViewCellStyleDefault

    UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
    cell.textLabel.text = @"dafasdfa";
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    cell.detailTextLabel.text = @"detaildetaildetaildetaildetail";
    cell.imageView.image = [UIImage imageNamed:@"屏幕快照 2015-05-17 22.01.27"];

UITableViewCellStyleValue1

    UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"cell"];
    cell.textLabel.text = @"dafasdfa";
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    cell.detailTextLabel.text = @"detaildetaildetaildetaildetail";
    cell.imageView.image = [UIImage imageNamed:@"屏幕快照 2015-05-17 22.01.27"];

UITableViewCellStyleValue2

    UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:@"cell"];
    cell.textLabel.text = @"dafasdfa";
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    cell.detailTextLabel.text = @"detaildetaildetaildetaildetail";

UITableViewCellStyleSubtitle

    UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"cell"];
    cell.textLabel.text = @"dafasdfa";
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    cell.detailTextLabel.text = @"detaildetaildetaildetaildetail";
    cell.imageView.image = [UIImage imageNamed:@"屏幕快照 2015-05-17 22.01.27"];

下面是设置cell的属性介绍
//cell的右边辅助按钮的样式
    cell.accessoryType = UITableViewCellAccessoryCheckmark;
    //自定义cell右边的辅助按钮
    cell.accessoryView = nil;
    //自定义cell的背景
    cell.backgroundView = nil;
    //设置cell的contentview中的detail的文字内容
    cell.detailTextLabel.text = @"";
    //查看cell当前的编辑模式
    int style = cell.editingStyle;
    //设置当cell进入编辑模式时的辅助按钮样式
    cell.editingAccessoryType = UITableViewCellAccessoryDisclosureIndicator;
    //自定义cell进入编辑模式后辅助按钮
    cell.editingAccessoryView = nil;
    //获取cell的缩进级别
    int level = cell.indentationLevel;
    //获取cell的缩进宽度
    float width = cell.indentationWidth;
    //设置cell被选中时的背景
    cell.selectedBackgroundView = nil;
    //设置cell的选中状态样式
    cell.selectionStyle = UITableViewCellSelectionStyleBlue;
    //设置cell的contentview中的textlabel文字内容
    cell.textLabel.text = @"";

转载于:https://www.cnblogs.com/AbeDay/p/5026927.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值