Raf*_*fal 1 objective-c uitableview ios
我想让UITableViewCell文本颜色在选中时更改,但仅限于此.我想禁用单元格中的背景突出显示.我看到了解决方案:
cell.selectionStyle = UITableViewCellSelectionStyleNone;
Run Code Online (Sandbox Code Playgroud)
但这也会禁用文本颜色更改.我想以简单的方式实现这种行为吗?
在你的cellForRowAtIndexPath,做:
步骤1.将您的选择样式设置为默认值.
cell.selectionStyle = UITableViewCellSelectionStyleDefault;
Run Code Online (Sandbox Code Playgroud)
步骤2.将空视图设置为背景视图
UIView *view = [UIView new] ;
[view setBackgroundColor:[UIColor clearColor]];
[cell setSelectedBackgroundView:view];
Run Code Online (Sandbox Code Playgroud)
第3步.设置所需的文字颜色
[[cell textLabel] setTextColor:[UIColor orangeColor]];
[[cell textLabel] setHighlightedTextColor:[UIColor blackColor]];
Run Code Online (Sandbox Code Playgroud)
希望这可以帮助.
| 归档时间: |
|
| 查看次数: |
1252 次 |
| 最近记录: |