Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Don';t对UITableViewCell使用默认焦点动画_Uitableview_Focus_Tvos - Fatal编程技术网

Don';t对UITableViewCell使用默认焦点动画

Don';t对UITableViewCell使用默认焦点动画,uitableview,focus,tvos,Uitableview,Focus,Tvos,我有一个非常简单的单元格,我希望文本在聚焦时为1.0alpha,在非聚焦时为0.5。这是通过覆盖didUpdateFocusInText import Foundation class SettingsTableViewCell: UITableViewCell { override func didUpdateFocusInContext(context: UIFocusUpdateContext, withAnimationCoordinator coordinator: UIFocu

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

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

}
}

但是,我不希望在聚焦时出现白色背景。。。如何摆脱它


将单元格的
焦点样式设置为
UITableViewCellFocusStyleCustom
和UIKit在单元格上根本不会显示任何默认焦点:这完全取决于您。

将单元格的
焦点样式设置为
UITableViewCellFocusStyleCustom
和UIKit在单元格上根本不会显示任何默认焦点样式细胞:这完全取决于你