フォーカス移動の検知
override func didUpdateFocusInContext(context: UIFocusUpdateContext, withAnimationCoordinator coordinator: UIFocusAnimationCoordinator) {
context.nextFocusedView?.backgroundColor = UIColor.grayColor()
context.previouslyFocusedView?.backgroundColor = nil
}
最初にフォーカスされるビューの指定
override var preferredFocusedView: UIView? {
return ボタン名
}
ボタンが押された時の処理
ボタン名.addTarget(self, action: #selector(呼び出すメソッド), forControlEvents: UIControlEvents.PrimaryActionTriggered)
わからないこと
- スワイプでフォーカスが移動しない場合の対応
- 左右タップの取得方法 (取得できる?)
参考