Reputation: 3564
I am trying to animate between 2 subviews. At the moment I've tried different options, each with their own side effects.
The application is a small game with a skills subview, an inventory subview, and a status subview. I want to animate between the skills and the inventory views while leaving the status subview on the bottom of the main view. Below I've listed my various attempts and the side effects from them.
Animate from `animateWithDuration
[UIView animateWithDuration:0.3 delay:0.3 options:UIViewAnimationOptionTransitionFlipFromRight | UIViewAnimationCurveEaseIn animations:^{
skillView.hidden = NO;
inventoryView.hidden = YES;
}completion:NULL];
Animate from transitionFromView
[UIView transitionFromView:inventoryView toView:skillView duration:0.5 options:UIViewAnimationOptionTransitionFlipFromRight completion:^(BOOL finished){
inventoryView.hidden = YES;
}];
The views are loaded into the main view just hidden in the background and they used to just pop into the main window. However, I would like to animate between the views to have a better application flow. I've seen people remove and add to the main view, but I'm hoping that setting the subviews to be visible/invisible should have the same effect.
Any advice is greatly appreciated.
Upvotes: 0
Views: 425
Reputation: 31662
Core Animation doesn't know how to animate those views apart from their direct ancestor (parent).
Break them into a single container view.
Eg:
Instad of this:
Parent
- Other View
- View A
- View B
- Other View
Have this:
Parent
- Other View
- Container
- View A
- View B
- Other View
See comments to question for more detail.
Upvotes: 1