gpt4 book ai didi

objective-c - 如何在 tvOS 中设置 TableViewCell 焦点颜色

转载 作者:太空狗 更新时间:2023-10-30 03:53:53 26 4
gpt4 key购买 nike

UITableViewCell 的默认焦点颜色是白色。我们如何更改 UITableView 单元格的焦点颜色?

最佳答案

您可以在下面的代码中进行设置:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
// ...
cell.focusStyle = UITableViewCellFocusStyleCustom;
// ...
return cell;
}

- (void)tableView:(UITableView *)tableView didUpdateFocusInContext:(UITableViewFocusUpdateContext *)context withAnimationCoordinator:(UIFocusAnimationCoordinator *)coordinator
{
if ([context.previouslyFocusedView isKindOfClass:[UITableViewCell class]])
context.previouslyFocusedView.backgroundColor = [UIColor clearColor];
if ([context.nextFocusedView isKindOfClass:[UITableViewCell class]])
context.nextFocusedView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.3];
}

关于objective-c - 如何在 tvOS 中设置 TableViewCell 焦点颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34149496/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com