I am creating a tvOS app and I want to use parallax images on a couple of buttons. From the docs:
To incorporate parallax images in your app:
- Create a UIImage object.
- You load the image differently depending on whether the image is included in your app bundle or whether you have downloaded the image.
- Bundle—Load images using imageNamed:.
- Downloaded file—Load images using imageWithContentsOfFile:.
- Create a new UIImageView object using the loaded images.
- If the UIImageView is part of another view, set adjustsImageWhenAncestorFocused to YES on the UIImageView.
I know it says UIImageView
there, but I was hoping to make the same effect happen on a UIButton
, like the home screen app icons.
I've created the artwork, made a stack in the asset catalog, and loaded the image with imageNamed:
, but the UIButton
does not behave like a parallax image. It does not sway around like the home-screen icons do. It just looks like a flat image.
Is there something else I have to enable in order for the UIButton
to behave like the home screen app icons?
UIButton* quitGame = [[UIButton alloc] initWithFrame:rectWithNewX(playAgain.frame, 985)];
[quitGame setImage:[UIImage imageNamed:@"quit.lsr"] forState:UIControlStateNormal];
[quitGame setAdjustsImageWhenHighlighted:YES];
fadeIn(quitGame, self.view, 0.5);