This examples shows how to Curl Up a
UIView with animation effect.
You can download source code from here Download.
@interface FirstViewController : UIViewController {
IBOutlet UIView *viewSecond;
IBOutlet UIView *viewFirst;
}
- (IBAction)btnSecondView_Clicked:(id)sender;
- (IBAction)btnFirstView_Clicked:(id)sender;
@end
#import "FirstViewController.h"
@implementation FirstViewController
- (void)viewDidLoad {
[super viewDidLoad];
}
- (void)btnSecondView_Clicked:(id)sender {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDelegate:self];
[UIView setAnimationDuration:2.0];
[viewSecond setAlpha:0.0];
[viewFirst setAlpha:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:viewSecond cache:YES];
[UIView commitAnimations];
}
- (IBAction)btnFirstView_Clicked:(id)sender {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDelegate:self];
[UIView setAnimationDuration:2.0];
[viewFirst setAlpha:0.0];
[viewSecond setAlpha:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:viewFirst cache:YES];
[UIView commitAnimations];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
- (void)dealloc {
[super dealloc];
}
@end
Code for .h file.
#import @interface FirstViewController : UIViewController {
IBOutlet UIView *viewSecond;
IBOutlet UIView *viewFirst;
}
- (IBAction)btnSecondView_Clicked:(id)sender;
- (IBAction)btnFirstView_Clicked:(id)sender;
@end
Code for .m file.
#import "FirstViewController.h"
@implementation FirstViewController
- (void)viewDidLoad {
[super viewDidLoad];
}
- (void)btnSecondView_Clicked:(id)sender {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDelegate:self];
[UIView setAnimationDuration:2.0];
[viewSecond setAlpha:0.0];
[viewFirst setAlpha:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:viewSecond cache:YES];
[UIView commitAnimations];
}
- (IBAction)btnFirstView_Clicked:(id)sender {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDelegate:self];
[UIView setAnimationDuration:2.0];
[viewFirst setAlpha:0.0];
[viewSecond setAlpha:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:viewFirst cache:YES];
[UIView commitAnimations];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
- (void)dealloc {
[super dealloc];
}
@end
No comments:
Post a Comment