How to focus UIButton and UILabel?

Apologies for what's probably a very basic question, but I'm spinning my wheels on something that shouldn't be that hard. I've seen plenty of examples of tvOS apps that have a UIButton thumbnail w/ label that both gain focus when selected. The Apple Music video from the tvOS Human Interface Guidelines is a good demonstration of what I'm talking about. I've experimented with a bunch of different ways of making my buttons, but I can't seem to figure out how to get both the UIButton and its corresponding label to gain focus. I've added a UIButton and a UILabel as subviews of a UIView, I've added UIImageView and UITextView as subviews of a subview of UIButton, and a few other combinations, but nothing seems to work. I'm able to get the image to focus, but never the image *and* the label. Is there an optimal solution for creating these kinds of buttons? Thanks!

I think that sort of thing is normally done using the UIFocusEnvironment protocol implemented by UIView. didUpdateFocusInContext is called when focus changes. In your implementation of that method you would call addCoordinatedAnimations() on the coordinator to animate your changes to the label so it "looks" like it's focused, though it's actually the button or other view that's receiving the focus change.


You might need to subclass UIButton to make that happen in your case; I'm not sure. I'm doing it in a UICollectionViewCell where I have an image that adjusts when ancestor is focused. So it acts like a button.

How to focus UIButton and UILabel?
 
 
Q