Mad*_*adu 5 uitextview uilabel uiappearance tvos
我正在构建一个tvos应用程序,我希望UITextView的行为类似于tvos电影应用程序.我对专注的外表特别感兴趣.请看看这两张照片.
目前我只是在聚焦时为textview添加背景颜色,但是如何在附加图像中实现这种聚焦外观.这是我的小代码
override func didUpdateFocusInContext(context: UIFocusUpdateContext, withAnimationCoordinator coordinator: UIFocusAnimationCoordinator) {
super.didUpdateFocusInContext(context, withAnimationCoordinator: coordinator)
if context.previouslyFocusedView == lessonDescriptionTxt {
coordinator.addCoordinatedAnimations({ () -> Void in
self.lessonDescriptionTxt.layer.backgroundColor = UIColor.clearColor().CGColor
}, completion: nil)
}
if context.nextFocusedView == lessonDescriptionTxt {
coordinator.addCoordinatedAnimations({ () -> Void in
self.lessonDescriptionTxt.layer.backgroundColor = UIColor.blackColor().colorWithAlphaComponent(0.2).CGColor
}, completion: nil)
}
}
Run Code Online (Sandbox Code Playgroud)
此外,如果有人可以建议如何在有更多文本时在textView中实现此更多功能.我也读过这个问题让UILabel可以集中精力和可点击(tvOS),但这对我来说不起作用.
仅当说明无法容纳可用空间时,才会显示“更多”文本。您应该能够使用 UIKit 的方法来测量文本所需的空间量-[NSAttributedString boundingRectWithSize:options:context:]。
| 归档时间: |
|
| 查看次数: |
785 次 |
| 最近记录: |