选中cell

//选中第一分区的第一个cell 也可指定其它 cell

[self.tableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:NO scrollPosition:UITableViewScrollPositionNone];

//取消选中状态

[tableView deselectRowAtIndexPath:indexPath animated:NO];

cell 颜色

1.系统默认的颜色设置

1 //无色
2 cell.selectionStyle=UITableViewCellSelectionStyleNone;
3 //蓝色,也就是系统默认的颜色
4 cell.selectionStyle=UITableViewCellSelectionStyleBlue;
5 //灰色
6 cell.selectionStyle=UITableViewCellSelectionStyleGrap;

2.自定义UITableViewCell选中后的背景颜色和背景图片

1 UIColor* color=[[UIColor alloc]initWithRed:50/255.0 green:50/255.0 blue:50/255.0 alpha:1];//通过RGB来定义颜色 2 cell.selectedBackgroundView=[[UIView alloc]initWithFrame:cell.frame]autorelease]; 3 cell.selectedBackgroundView.backgroundColor=[UIColor ***]或color;  4 自定义选中后的背景图片 6 cell.selectedBackgroundView=[[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"backimg.png"]]autorelease]; 5 设置UITableViewCell中的字体颜色时用 8 cell.textLabel.highlightedTextColor=[UIColor **color];

3.定义UITableViewCell的样式

cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

accessoryType有如下几种

typedef enum {UITableViewCellAccessoryNone,UITableViewCellAccessoryDisclosureIndicator,UITableViewCellAccessoryDetailDisclosureButton,UITableViewCellAccessoryCheckmark
} UITableViewCellAccessoryType;

Cell分隔

1.隐藏UITableViewCell的分隔线

[chatTableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];

UITableViewCellSeparatorStyle有如下几种 
typedef enum {UITableViewCellSeparatorStyleNone,UITableViewCellSeparatorStyleSingleLine,UITableViewCellSeparatorStyleSingleLineEtched
} UITableViewCellSeparatorStyle;

2.设置UITableViewCell之间分隔线的颜色

[chatTableViewsetSeparatorColor:[UIColor blueColor]];

转载于:https://www.cnblogs.com/wei8/p/3205042.html

UITableViewCell 设置相关推荐

  1. UITableViewCell设置行距

    自定义UITableViewCell设置行距 创建Custom类继承自UITableViewCell 重写其-(instancetype)initWithStyle:(UITableViewCellS ...

  2. Swift - 表格图片加载优化(拖动表格时不加载,停止时只加载当前页图片)

    列表的单元格中包含有图片在开发中很常见.通常我们可以直接在tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIn ...

  3. ios开发问题汇总(一)

    教程汇总 IOS比较好的网络教程:IOS编程浅蓝教程 IOS编程教程(五)自定义UITableView的表单元格 菜鸟教程-iOS教程 开发问题 实现页面切换,网上某些文章写的是: [self.nav ...

  4. 具有多个单元格类型的iOS UITableView

    In this tutorial, we'll be developing an iOS Application using Swift that has a single iOS UITableVi ...

  5. Swift - UITableView

    创建UITablView import UIKitclass ViewController: UIViewController,UITableViewDataSource,UITableViewDel ...

  6. 800000000000

    8000000000题@TOC 不属于使用SDWebImage步骤的是 A:下载SDWebImage的最新SDK​ B:把SDK导入工程中BackgroundColor​ C:关闭arc​ D:如果需 ...

  7. iOS常见控件的基本使用

    文章目录 @[toc] UI相关类继承关系 UIView 常见属性和方法 1. UIView属性 3. UIControl 常用控件 1. UIImageView 图片显示控件(android Ima ...

  8. iOS UI入门——使用Objective-C和Swift简单实现UITableView

    Objective-C代码: #import "ViewController.h"@interface ViewController ()<UITableViewDelega ...

  9. swift 4 tableViewCell动态加载网络图片问题处理

    1. 很多APP都会涉及到资讯或帖子或主题详情页的界面,其中就涉及到cell加载网络图片的开发问题. 2. 最容易想到的思路就是把URL直接传递给cell,让cell的imageView控件直接使用S ...

最新文章

  1. ftok file php,Linux和PHP中的ftok函数返回值不一致问题跟踪
  2. C语言强数Strong number算法(附完整源码)
  3. DataTable添加行的方法
  4. 电脑打字手指正确姿势_正确的投篮姿势教学,许多人都忽略的细节,学会变投篮神射手...
  5. python发人人状态
  6. 为myeclipse分配更大的内存
  7. mybatis 添加语句返回对象_Mybatis底层源码分析
  8. 301跳转 https_http跳转https和https跳转http的两种301重定向代码
  9. Jzoj3898 树的连通性
  10. Android开发网
  11. websocket实现实时直播
  12. 排队模型和排队系统仿真
  13. JS点击按钮打开新的独立页面
  14. 【网络空间安全】与【信息安全】专业介绍
  15. 电信猫的无线无法连接服务器,光纤猫连接路由器无法上网怎么办
  16. 【软件构造】小谈designing patterns
  17. 人参果水果宣传文案模版,水果店文案人参果
  18. 操作系统知识盘点(四)(内存技术)
  19. 抗阿达木单抗的抗体可能与阿达木单抗治疗过程中静脉和动脉血栓事件相关
  20. 全民养猪(手机游戏 攻略)

热门文章

  1. 修复 SyntaxHighlighter 3.0.83 Java 代码多行注释 Bug
  2. DataGrid 中的特殊应用
  3. Summary of the Academic English Class
  4. valid, satisfiable, unsatisfiable的例子
  5. 关于MonoBehaviour的单例通用规则
  6. 【转】SVN 与 GIT 详细对比
  7. 笔记-TCPCLIENT
  8. 数据蒋堂 | 怎样看待存储过程的移植困难
  9. Linux服务器CPU、内存、磁盘空间、负载情况查看python脚本
  10. websocket 历史及使用详解