【tvOS】UIFocusGuide


問題

先端のボタンから、「追加」のボタンへFocusできないこと。

解決

sensei.swift
    @IBOutlet weak var addBtn: UIButton!
    @IBOutlet weak var senseiCollection: UICollectionView!
    private let focusGuide = UIFocusGuide()
    override func viewDidLoad() {
        super.viewDidLoad()
        view.addLayoutGuide(focusGuide)

        focusGuide.topAnchor.constraint(equalTo: addBtn.topAnchor).isActive = true
        focusGuide.leftAnchor.constraint(equalTo: senseiCollection.leftAnchor).isActive = true

        focusGuide.heightAnchor.constraint(equalTo: addBtn.heightAnchor).isActive = true
        focusGuide.widthAnchor.constraint(equalTo: senseiCollection.widthAnchor).isActive = true

        focusGuide.preferredFocusEnvironments = [addBtn]
    }