I have this code:
- (void) displayView:(int)intNewView{
NSLog(@"%i", intNewView);
[currentView.view removeFromSuperview];
[currentView release];
switch (intNewView) {
case 1:
currentView = [[EnterView alloc] init];
break;
case 2:
currentView = [[MainMenuView alloc] init];
break;
case 3:
currentView = [[DetailsView alloc] init];
break;
case 4:
currentView = [[PhotosView alloc] init];
break;
case 5:
currentView = [[CustomUITableViewViewController alloc] init];
break;
}
[self.view addSubview:currentView.view];
}
This code successfully transitions views, however its not very spectacular as you can imagine (the view simply switches with no animation). I'm wondering if there is a simple way to add any kind of simple view transition animation here? I can't figure out how to implement any of the example I've found online. Any animation would suffice, just something to spice things up a bit :)
Thanks,
Jack
Create ImageView in the activity_main. xml along with buttons that will add animation to the view. Navigate to the app > res > layout > activity_main. xml.
Transitions are animations used to keep users oriented during user interface (UI) state changes and object manipulations, and make those changes feel smooth instead of jarring. Good transitions feel natural, often giving the illusion that users are interacting with real-world objects.
Android's transition framework allows you to animate all kinds of motion in your UI by simply providing the starting layout and the ending layout.
You can simply use basic core animations:
Like this:
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:2];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.view cache:YES];
[self.view addSubview:currentView.view];
[UIView commitAnimations];
You can try different UIViewAnimationTransitions, for the "forView" you enter the view that currently is on the screen. Hope that helped.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With