我试图覆盖canBecomeFocused但没有发生任何事情.
所以问题是我没注意到我的细胞得到了关注.要包装它,您需要实现1)覆盖canBecomeFocused
2)覆盖“dIDUpdateFocusInContext:withAnimationCoordinator:”方法,以便能够将细胞突出显示为聚焦
Swift 2.3:
overrIDe func canBecomeFocused() -> Bool { return true}overrIDe func dIDUpdateFocusInContext(context: UIFocusUpdateContext,withAnimationCoordinator coordinator: UIFocusAnimationCoordinator) { if context.nextFocusedVIEw == self { coordinator.addCoordinatedAnimations({ () -> VoID in self.layer.backgroundcolor = UIcolor.bluecolor().colorWithAlphaComponent(0.2).CGcolor },completion: nil) } else if context.prevIoUslyFocusedVIEw == self { coordinator.addCoordinatedAnimations({ () -> VoID in self.layer.backgroundcolor = UIcolor.clearcolor().CGcolor },completion: nil) }}
斯威夫特3:
overrIDe var canBecomeFocused: Bool { return true}overrIDe func dIDUpdateFocus(in context: UIFocusUpdateContext,with coordinator: UIFocusAnimationCoordinator) { if context.nextFocusedVIEw == self { coordinator.addCoordinatedAnimations({ () -> VoID in self.layer.backgroundcolor = UIcolor.blue.withAlphaComponent(0.2).cgcolor },completion: nil) } else if context.prevIoUslyFocusedVIEw == self { coordinator.addCoordinatedAnimations({ () -> VoID in self.layer.backgroundcolor = UIcolor.clear.cgcolor },completion: nil) }}总结
以上是内存溢出为你收集整理的swift – 如何使用Apple TV上的焦点引擎使UIView成为焦点全部内容,希望文章能够帮你解决swift – 如何使用Apple TV上的焦点引擎使UIView成为焦点所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)