Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

nacho4d

macrumors newbie
Original poster
Jul 13, 2008
23
0
Hi everyone.
I would like to give my UIViews the "turning pages" (maybe more like tearing off a newspaper from the corner or something like google maps application toolbar's right button but completely turn the page) effect.

Any thoughts?
I don't know where to begin to read. Maybe Core Animation? Transitions? OpenGL ES? .
If someone could give some advices about what Classes to use or maybe useful methods, It would be awesome.
Thanks in advance.:)
Ignacio.
 

jstanier

macrumors regular
Sep 6, 2008
148
0
Brighton, England.
Apologies for the massive chunk of code, but it should be fairly readable. When the method is called it toggles between two views, using page curl up and curl down. I think I got this code from one of the Apple code samples a very long time ago, but I can't remember which one.

With regards to the "partial" curl up that Google Maps does, I don't know how to do that - never found out!

Code:
-(void)toggleView {
		/*
		 This method is called when the info or Done button is pressed.
		 It flips the displayed view from the main view to the flipside view and vice-versa.
		 */
		if (infoViewController == nil) {
			[self loadInfoViewController];
		}
		
		UIView *mainView = imageViewController.view;
		UIView *flipsideView = infoViewController.view;
		
		[UIView beginAnimations:nil context:NULL];
		[UIView setAnimationDuration:1];
		[UIView setAnimationTransition:([mainView superview] ? UIViewAnimationTransitionCurlUp : UIViewAnimationTransitionCurlDown) forView:self.view cache:YES];
		
		if ([mainView superview] != nil) {
			[infoViewController viewWillAppear:YES];
			[imageViewController viewWillDisappear:YES];
			[mainView removeFromSuperview];
			[self.view addSubview:flipsideView];
			[imageViewController viewDidDisappear:YES];
			[infoViewController viewDidAppear:YES];
			
		} else {
			[imageViewController viewWillAppear:YES];
			[infoViewController viewWillDisappear:YES];
			[flipsideView removeFromSuperview];
			[self.view addSubview:mainView];
			[infoViewController viewDidDisappear:YES];
			[imageViewController viewDidAppear:YES];
			[infoViewController release];
			infoViewController = nil;
		}
		[UIView commitAnimations];
}
 

nacho4d

macrumors newbie
Original poster
Jul 13, 2008
23
0
Thanks

I haven't try it ,if it is from apple samples it should be correct.

This is exactly what I was looking for, not exactly the parcial one, because I want to swap the my views so completely curl up is what I was looking for!.

Thanks again.:)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.