iOS中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:0.0 green:0.0 blue:0.0 alpha:1];//通过RGB来定义颜色
2 cell.selectedBackgroundView=[[UIView alloc]initWithFrame:cell.frame]autorelease];
3 cell.selectedBackgroundView.backgroundColor=[UIColor   ***]或color;
4 
5 自定义选中后的背景图片
6 cell.selectedBackgroundView=[[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"123.png"]]autorelease];
7 设置UITableViewCell中的字体颜色时用
8 cell.textLabel.highlightedTextColor=[UIColor **color];
复制代码

3.定义UITableViewCell的样式

  

cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

不设置accessoryType时是这样的

设置accessoryType后是这样的

发没发现其中的差别,要仔细看哦,不仔细看可能看不出来哦

accessoryType有如下几种

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

4.隐藏UITableViewCell的分隔线

    [chatTableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];

   UITableViewCellSeparatorStyle有如下几种 

5设置UITableViewCell之间分隔线的颜色

 [chatTableViewsetSeparatorColor:[UIColor blueColor]];

还有其他颜色可以设置,你们可以自已试试

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值