2015-12-08 4 views
5

私はtvosアプリケーションを構築していますが、私はUITextViewをtvos Moviesアプリケーションのように動作させたいと考えています。私は特に注目を集めています。この2枚の写真を見てください。 Normal Imagetvos:ムービーのようなUITextViewフォーカスの外観App

Focused TextView

現在、それがフォーカスされたときに、私はただのTextViewに背景色を追加することですが、私は、添付画像では、この集中外観を達成することができますか。誰かがより多くのテキストがあるとき、私はTextViewの中で、このMORE機能を実現する方法を提案することができればここに私の小さなコード

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

もあります。私もこの質問Make UILabel focusable and tappable (tvOS)を読むが、それは私の仕事をしません。

答えて

0

"MORE"テキストは、説明が利用可能なスペースに収まらない場合にのみ表示されます。 UIKitの-[NSAttributedString boundingRectWithSize:options:context:]メソッドを使用すると、テキストに必要な領域を測定できるはずです。

+0

弾力のある外観は選択するとどうなりますか? – Madu

+0

この要点https://gist.github.com/Cedrick84/8922a0af730c39c05794は、「バウンシー」モーションエフェクトを実装しています。 –

関連する問題