UITableViewCell的选择颜色

Sop*_*ert 3 iphone cocoa-touch uitableview iphone-sdk-3.0

如果我有一个自定义UITableViewCell不使用textLabel单元格的内置而是自己的绘图,我如何更改选择的外观contentView,就像它自动为默认文本(可通过设置自定义selectedTextColor:)?

如果我改变了tableView:willSelectRowAtIndexPath:,那么它只会在蓝色选择背景启动后更新,但不会在它动画时更新,就像我想要的那样.

Tho*_*mas 6

只是不要继承UITableViewCell并使用默认行为.您可以完全自定义单元格而无需任何子类.

阅读本文了解更多详情.


Sun*_*rge 5

在tableview cellForRowAtIndexPath方法中添加此代码,只需更改UITableViewCell选择样式的预期颜色.

   //-------------------------------------------------------------------------
   //background selected view 
   UIView *viwSelectedBackgroundView=[[UIView alloc]init];
   viwSelectedBackgroundView.backgroundColor=[UIColor colorWithRed:124.0/255.0 green:202.0/255.0 blue:227.0/255.0 alpha:1.0];
   cell.selectedBackgroundView=viwSelectedBackgroundView;
   //-------------------------------------------------------------------------
Run Code Online (Sandbox Code Playgroud)