自定义UITableViewCell的背景样式

本文介绍了如何自定义UITableViewCell的背景样式,包括改变选中时的背景色、自定义选中状态的背景以及调整字体颜色。通过设置backgroundView和backgroundColor属性,可以实现对cell背景的个性化设置。同时,文章提及在plain-style和grouped-style的TableView中backgroundView的默认行为。此外,作者邀请iPhone开发者加入相关QQ群进行交流讨论。
摘要由CSDN通过智能技术生成

1.改变UITableViewCell选中时背景色

 cell.selectedBackgroundView = [[[UIView alloc] initWithFrame:cell.frame] autorelease];
 cell.selectedBackgroundView.backgroundColor = [UIColor xxxxxx];

2.自定义UITableViewCell选中时背景

 cell.selectedBackgroundView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"cellart.png"]] autorelease]; 

3. 字体颜色

 cell.textLabel.highlightedTextColor = [UIColor xxxcolor];

4.清楚grouped-style的背景

UITableViewCell的文档中描述,backgroundView在plain-style的TableView里面是nil,在grouped-style的TableView里面并不是空的,有一个系统的默认值,所以这里置空一下就ok了。

UIView *tempView = [[[UIView alloc] init] autorelease];
[cell setBackgroundView:tempView];
[cell set
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值