Created
November 6, 2015 10:30
Revisions
-
dedeexe created this gist
Nov 6, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,41 @@ // // FocusView.swift // CustomNavigation // // Creating a CustomFocusView // This code shows how to implement a custom view that can be focused in tvOS // Just set this class as an UIView's custom class // import UIKit class CustomFocusView: UIView { //Now This View controller can get Focus override func canBecomeFocused() -> Bool { return true } //We Can chance the focus behavior.... Is a good idea if we evidence it override func didUpdateFocusInContext(context: UIFocusUpdateContext, withAnimationCoordinator coordinator: UIFocusAnimationCoordinator) { //Bahavior we will trigger when view lost focus if context.previouslyFocusedView === self { UIView.animateWithDuration(0.1, animations: { () -> Void in context.previouslyFocusedView?.transform = CGAffineTransformMakeScale(1.0, 1.0) }) } //Bahavior we will trigger when view get focus if context.nextFocusedView === self { UIView.animateWithDuration(0.1, animations: { () -> Void in context.nextFocusedView?.transform = CGAffineTransformMakeScale(1.2, 1.2) }) } } }