【问题标题】:Don't use default focus animation for UITableViewCell不要为 UITableViewCell 使用默认的焦点动画
【发布时间】:2015-11-19 00:13:05
【问题描述】:

我有一个非常简单的单元格,我希望文本在聚焦时为 1.0 alpha,在未聚焦时为 0.5。这可以通过覆盖 didUpdateFocusInContext

import Foundation

class SettingsTableViewCell: UITableViewCell {


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

    var textColor:UIColor?

    if self.focused == true {
        textColor = UIColor.blackColor().colorWithAlphaComponent(1.0)
    } else {
        textColor = UIColor.blackColor().colorWithAlphaComponent(0.5)
    }

    let attributedTitle = self.textLabel?.attributedText?.mutableCopy() as! NSMutableAttributedString
    let range =  NSMakeRange(0, attributedTitle.length)
    attributedTitle.addAttribute(NSForegroundColorAttributeName, value: textColor!, range: range)
    self.textLabel?.attributedText = attributedTitle

}

}

但是,我不想要聚焦时的白色背景...如何摆脱它?

【问题讨论】:

    标签: uitableview focus tvos


    【解决方案1】:

    将单元格的focusStyle 设置为UITableViewCellFocusStyleCustom,UIKit 根本不会在单元格上执行任何默认焦点外观:这完全取决于您。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-02-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多