2016-03-01 66 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() 
    } 
} 
相關問題