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

jchildress

macrumors member
Original poster
Jul 9, 2008
49
0
I'm using the "UIViewAnimationTransitionFlipFromRight" command to flip a view from right to left, and then again from left to right to go back. As the view flips, the distinctive empty black background behind the flipping view animation, in my opinion, is ugly.

I think I can change the background color, but I thought it would be really cool if I can have an image back there instead. So I tried to add a UIImageView to the window in the MainWindow.XIB, but that did nothing. Does anybody have any ideas on how to do this?
 
I've never seen this done before. Increase the speed of your animation if you don't like the colour behind the flip to reduce its exposure time. Either that or change the animation to UIViewAnimationTransitionCurlUp for a cool fade effect, both animations are visually impressive from a users point of view.
 
jchildress - The point of a UIViewAnimationTransitionFlipFromRight is to flip the view to some other view. The right way to use it is like this:

Code:
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.75];     /* Sub. duration here */
		
UIView *superview;
if ((superview = [frontSideView superview])) {
	[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:superview cache:YES];
	[frontSideView removeFromSuperview];
	[superview addSubview:backSideView];
} else if ((superview = [backSideView superview])) {
	[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:superview cache:YES];
	[backSideView removeFromSuperview];
	[superview addSubview:frontSideView];
}

[UIView commitAnimations];

Of course you need to make sure that the views are elsewhere retained when you do this because -removeFromSuperview sends a -release message to its target.

I've never seen this done before. Increase the speed of your animation if you don't like the colour behind the flip to reduce its exposure time. Either that or change the animation to UIViewAnimationTransitionCurlUp for a cool fade effect, both animations are visually impressive from a users point of view.

UIViewAnimationTransitionCurlUp is only a fade on the iPhone Simulator - on the device, its the animation its actually supposed to be, which is the curl up (and away) animation.
 
On a related note, does anybody know if it is possible to flip a view inside a tab bar controller? I can't quite get my head around it
 
It's just the same.

What seems to be the problem you're having?

I've got a tab bar with 5 tabs, each with their own view in. I want to be able to touch that view and then flip it over to reveal another view. The thing is I'm not sure how to target each specific tab in the tab bar using the code. It's probably quite simple and I've a feeling I'd need to use something like tabBarController.selectedIndex = 0; but I can't get it working.
 
TripleJ, that's what I'm doing and it works for me. I'm at work and currently away from my code. but I can post it later if you need me to. What I'm doing is pretty hacky due to my inexperiance with Obj-C. So maybe other people can critique my code and tell me how to improve it. but it works for me.

One thing I'd like to know... Can I modify a single index value in an NSArray. for example. I want to get the array of currentViewControllers from my tabBarController and then swap out a specific controller with a new one. In other languages I'm used to, I would try something like this:

myArray[0] = newViewController;

Is there a "setObjectAtIndex" method for an NSArray? So something like:

[myArray setObjectAtIndex:newViewController];

Thanks,
Jason
 
TripleJ, that's what I'm doing and it works for me. I'm at work and currently away from my code. but I can post it later if you need me to. What I'm doing is pretty hacky due to my inexperiance with Obj-C. So maybe other people can critique my code and tell me how to improve it. but it works for me.

If you could, Jason, that would be very much appreciated :) Thank you in advance!
 
Use UIColor's colorWithPatternImage

self.parentViewController.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:mad:"img.png"]];
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.