IOS - UITableViewCell的选中时的颜色及tableViewCell的selecte与deselecte
?
?
2.自定義顏色和背景設(shè)置
?改變UITableViewCell選中時(shí)背景色:
?
UIColor?*color = [[UIColoralloc]initWithRed:0.0green:0.0blue:0.0alpha:1];//通過RGB來定義自己的顏色
[html]?view plaincopy?
?
3自定義UITableViewCell選中時(shí)背景
[html]?view plaincopy?
?
4.設(shè)置tableViewCell間的分割線的顏色
[theTableView setSeparatorColor:[UIColor xxxx ]];
4.pop返回table時(shí),cell自動(dòng)取消選中狀態(tài)
首先我有一個(gè)UITableViewController,其中每個(gè)UITableViewCell點(diǎn)擊后都會(huì)push另一個(gè)ViewController,每次點(diǎn)擊Cell的時(shí)候,Cell都會(huì)被選中,當(dāng)從push的ViewController返回的時(shí)候選中的Cell便會(huì)自動(dòng)取消選中。后來由于某些原因我把這個(gè)UITableViewController改成了UIViewController,之后就產(chǎn)生了一個(gè)問題:每次返回到TableView的時(shí)候,之前選中的Cell不能自動(dòng)取消選中,經(jīng)過查找得知:
UITableViewController有一個(gè)clearsSelectionOnViewWillAppear的property,
而當(dāng)把UITableViewController修改成UIViewController后,這個(gè)屬性自然就不存在了,因此我們必須手動(dòng)添加取消選中的功能,方法很簡單,在viewWillAppear方法中加入:
[self.tableView deselectRowAtIndexPath:[self.tableView indexPathForSelectedRow] animated:YES];
?
?
6.點(diǎn)擊后,過段時(shí)間cell自動(dòng)取消選中
?- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
?????…………
????//消除cell選擇痕跡
????[self performSelector:@selector(deselect) withObject:nil afterDelay:0.5f];
}
- (void)deselect
{
????[self.tableview deselectRowAtIndexPath:[self.tableview indexPathForSelectedRow] animated:YES];
}
轉(zhuǎn)載于:https://www.cnblogs.com/mcj-coding/p/3606897.html
總結(jié)
以上是生活随笔為你收集整理的IOS - UITableViewCell的选中时的颜色及tableViewCell的selecte与deselecte的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: oracle中的一些基本概念
- 下一篇: 一步步学习SPD2010--第十章节--