Cla*_*aus 0 background background-color uitableview ios5.1 uiappearance
我的应用程序在不同的屏幕中显示分组的静态UITableViews.无论如何使用外观代理
[UITableView appearance]
Run Code Online (Sandbox Code Playgroud)
要么
[UITableViewCell appearance]
Run Code Online (Sandbox Code Playgroud)
自定义所选单元格的背景颜色?基本上我需要修改
cell.selectedBackgroundView.backgroundColor
Run Code Online (Sandbox Code Playgroud)
对于我的应用程序中的每个单元格,但我找不到在代理对象中设置的正确属性.
顺便说一下,我也试过了正常的方法(作为一个组静态表):
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
cell.selectedBackgroundView.backgroundColor = [UIColor yellowColor];
}
Run Code Online (Sandbox Code Playgroud)
但它不起作用.有什么建议吗?
您需要提供selectedBackgroundView的视图.已经没有人了.尝试:
cell.selectedBackgroundView = [[UIView alloc] initWithFrame:cell.bounds] ;
cell.selectedBackgroundView.backgroundColor = [UIColor yellowColor] ;
Run Code Online (Sandbox Code Playgroud)
此外,放置此代码(至少第一行)的更好位置是在-tableView:cellForRowAtIndexPath:
创建单元格时.否则,每次显示单元格时,您都将创建一个新的背景视图.
归档时间: |
|
查看次数: |
4859 次 |
最近记录: |