Screen Shot 2018-03-19 at 14.18.28.png

問題

先端のボタンから、「追加」のボタンへ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]
    }
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account log in.