UIButton on different Y level can't be focused on tvOS

夙愿已清 提交于 2019-12-05 01:28:31

So I was guided by apple to the solution. It requires a little coding using UIFocusGuide. Apple has a sample code for this.

Add a focus guide to fill in the missing space.

    let focusGuide = UIFocusGuide()
    view.addLayoutGuide(focusGuide)

    focusGuide.widthAnchor.constraintEqualToAnchor(buttonThatIsFocused.widthAnchor).active = true
    focusGuide.leftAnchor.constraintEqualToAnchor(buttonThatIsFocused.leftAnchor).active = true
    focusGuide.heightAnchor.constraintEqualToAnchor(buttonTryingToFocus).active = true

    focusGuide.preferredFocusedView = buttonTryingToFocus
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!