【问题标题】:Custom background on UITableViewCell on tvOStvOS 上 UITableViewCell 的自定义背景
【发布时间】:2016-03-01 16:07:28
【问题描述】:

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

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

任何帮助将不胜感激。

【问题讨论】:

    标签: swift uitableview tvos


    【解决方案1】:

    终于找到答案了!

    我必须继承 UITableViewCell 并覆盖 didUpdateFocusInContext,如下所示:

    override func didUpdateFocusInContext(context: UIFocusUpdateContext, withAnimationCoordinator coordinator: UIFocusAnimationCoordinator) {
    
        if context.nextFocusedView === self
        {
            self.backgroundColor = UIColor.grayColor()
        }
        else{
            self.backgroundColor = UIColor.clearColor()
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2016-04-07
      • 1970-01-01
      • 1970-01-01
      • 2011-08-22
      • 2010-09-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多