2016-03-01 27 views
0

我正在尝试为集中的UITableViewCell设置自定义背景。默认情况下,单元格会得到一个阴影,并且大小稍微增加,这是我完全想要移除的行为,并且只有在聚焦时才具有正常的背景颜色。tvOS上的UITableViewCell上的自定义背景

BTW我用斯威夫特2.

任何帮助将不胜感激。

回答

0

终于找到答案!

我有子类的UITableViewCell和覆盖didUpdateFocusInContext类似如下:

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

    if context.nextFocusedView === self 
    { 
     self.backgroundColor = UIColor.grayColor() 
    } 
    else{ 
     self.backgroundColor = UIColor.clearColor() 
    } 
} 
相关问题