Uitableview tvos抑制白色聚焦效果

Uitableview tvos抑制白色聚焦效果,uitableview,tvos,Uitableview,Tvos,我使用此代码设置UITableViewCells的焦点颜色: class EpisodesTableViewCell: UITableViewCell { override func didUpdateFocusInContext(context: UIFocusUpdateContext, withAnimationCoordinator coordinator: UIFocusAnimationCoordinator) { super.didUpdateFocus

我使用此代码设置UITableViewCells的焦点颜色:

class EpisodesTableViewCell: UITableViewCell {

    override func didUpdateFocusInContext(context: UIFocusUpdateContext, withAnimationCoordinator coordinator: UIFocusAnimationCoordinator) {

        super.didUpdateFocusInContext(context, withAnimationCoordinator: coordinator)

        if let previous = context.previouslyFocusedView as? EpisodesTableViewCell {
            previous.contentView.backgroundColor = UIColor.clearColor()
        }
        if let next = context.nextFocusedView as? EpisodesTableViewCell {
            next.contentView.backgroundColor = globalDarkGrey
        }
    }
}
颜色会根据需要变化,但在从一个桌子行移动到另一个桌子行时,通常会出现短暂的(相当刺激的)白色焦点颜色闪烁

通过不调用
super
我避免了闪光灯,但失去了点击动画


有没有关于如何完全去除白色的想法?

尝试更改
添加协调动画中的背景色

coordinator.addCoordinatedAnimations {
        if let previous = context.previouslyFocusedView as? EpisodesTableViewCell {
            previous.contentView.backgroundColor = UIColor.clearColor()
        }
        if let next = context.nextFocusedView as? EpisodesTableViewCell {
            next.contentView.backgroundColor = globalDarkGrey
        }
}

尝试更改
addCoordinatedAnimations
中的背景色:

coordinator.addCoordinatedAnimations {
        if let previous = context.previouslyFocusedView as? EpisodesTableViewCell {
            previous.contentView.backgroundColor = UIColor.clearColor()
        }
        if let next = context.nextFocusedView as? EpisodesTableViewCell {
            next.contentView.backgroundColor = globalDarkGrey
        }
}

上面的答案很接近,足以让我达到目的,但在这里它是一个可用的形式:

coordinator.addCoordinatedAnimations({
    if let previous = context.previouslyFocusedView as? EpisodesTableViewCell {
        previous.contentView.backgroundColor = UIColor.clearColor()
    }
    if let next = context.nextFocusedView as? EpisodesTableViewCell {
        next.contentView.backgroundColor = globalDarkGrey
    }
    }, completion: nil)

上面的答案很接近,足以让我达到目的,但在这里它是一个可用的形式:

coordinator.addCoordinatedAnimations({
    if let previous = context.previouslyFocusedView as? EpisodesTableViewCell {
        previous.contentView.backgroundColor = UIColor.clearColor()
    }
    if let next = context.nextFocusedView as? EpisodesTableViewCell {
        next.contentView.backgroundColor = globalDarkGrey
    }
    }, completion: nil)

谢谢,我已将此标记为正确答案,尽管下面添加了一些必要的调整。谢谢,我已将此标记为正确答案,尽管下面添加了一些必要的调整。