Tvos: UITextView focus like movies

I am creating a tvos application and I want the UITextView to behave the same as in the tvos Movies application. I am particularly interested in a focused appearance. Please take a look at these two photos. Normal image

Focused TextView

I am currently just adding a background color to the textview when it is focused, but how can I achieve this focused appearance in the attached images. here is my little code

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) } } 

Also if someone can suggest how can I achieve this MORE function in a textView when there is more text. I also read this question Make UILabel focused and tappOS (tvOS) , but it does not work for me.

+5
source share
1 answer

The text "MORE" appears only when the description cannot be placed in free space. You must be able to measure the amount of space needed for the text using the UIKit method -[NSAttributedString boundingRectWithSize:options:context:] .

0
source

Source: https://habr.com/ru/post/1237663/


All Articles