2016-04-05 44 views
0

我使用這個代碼設置UITableViewCells的顏色上聚焦白色焦點效果:tvos抑制

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我避免了閃光,但失去了點擊動畫。

任何有關如何擺脫白色的想法?

回答

1

嘗試改變內部addCoordinatedAnimations背景色:以上

​​
+0

謝謝,我知道標記爲正確答案,雖然下面添加了一些必要的調整。 – HenryRootTwo

0

答案是足夠接近,讓我在那裏,但在這裏它是一個可用的形式:

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)