gpt4 book ai didi

swift - tvOS 上 UITableViewCell 的自定义背景

转载 作者:行者123 更新时间:2023-11-30 13:39:32 25 4
gpt4 key购买 nike

我正在尝试为聚焦的 UITableViewCell 设置自定义背景。默认情况下,单元格会产生阴影,并且大小会稍微增加,这是我完全想删除的行为,并且在聚焦时只有正常的背景颜色。

顺便说一句,我正在使用 Swift 2。

任何帮助将不胜感激。

最佳答案

终于找到答案了!

我必须子类化 UITableViewCell 并重写 didUpdateFocusInContext,如下所示:

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

if context.nextFocusedView === self
{
self.backgroundColor = UIColor.grayColor()
}
else{
self.backgroundColor = UIColor.clearColor()
}
}

关于swift - tvOS 上 UITableViewCell 的自定义背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35727749/

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