UIView animated swap views (slide down) - iphone

This is what i have so far. What I am trying to do is make the starting view (startUpView) to switch to the other view (creatNewGameViewController) by sliding down the screen with the new view. All it does now is switch views normally, but i really want that sliding effect. If anyone can spot the error in my code it would be much appreciated. Thanks
#import "CreateNewGameViewController.h"
#synthesize createNewGameViewController;
UIButton *mainCreateGame = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[mainCreateGame addTarget:self
action:#selector(goToCreateGameViewController)
forControlEvents:UIControlEventTouchUpInside];
[mainScroll addSubview:mainCreateGame];
mainCreateGame.frame = CGRectMake(65, 10, 190, 60);
-(void)goToCreateGameViewController{
CreateNewGameViewController *newGame = [[CreateNewGameViewController alloc]initWithNibName:#"CreateNewGameViewController" bundle:nil];
self.createNewGameViewController = newGame;
CATransition *transition = [CATransition animation];
transition.duration = 2;
transition.timingFunction = [CAMediaTimingFunction
functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type =kCATransitionMoveIn;
CATransition *transition1 = [CATransition animation];
transition1.duration = 2;
transition1.timingFunction = [CAMediaTimingFunction
functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition1.type =kCATransitionMoveIn;
transition1.subtype =kCATransitionFromTop;
transition1.delegate = self;
[createNewGameViewController.view.layer addAnimation:transition1 forKey:nil];
transition1.subtype =kCATransitionFromTop;
transition1.delegate = self;
[self presentModalViewController:newGame animated:NO];
[self.view insertSubview:newGame.view atIndex:0];
[createNewGameViewController.view.layer addAnimation:transition1 forKey:nil];
[newGame release];

UIView has a class method called transition from view to view animated, check if that helps and tell me how it was :)
UiView
one piece of advice, you should really be using a navigation controller, a storyboard or something like it to do that kind of view transitions because is the proper way to do.

Related

how can I animate the UINavigationBar background change on UIViewController push?

My app uses two different backgrounds for the UINavigationBar to indicate to the user what level in the hierarchy they're at. When I push a UIViewController that needs the second background it lacks animation, the background changes immediately as soon as the UIViewController is pushed. How can I animate this so that the background change fades as the view is being changed?
I know this is an old thread, but this worked for me:
CATransition *transition = [CATransition animation];
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
transition.type = kCATransitionFade;
transition.duration = 0.5;
[self.navigationController.navigationBar.layer addAnimation:transition forKey:nil];
[self.navigationController.navigationBar setBackgroundImage:[[UIImage imageNamed:#"navigationbar.png"]resizableImageWithCapInsets:UIEdgeInsetsMake(44, 20, 44, 20)] forBarMetrics:UIBarMetricsDefault];
Place this inside your viewDidLoad method. You'll need to link/import the QuartzCore framework.

iPhone: changing CATransition causes UIActivityIndicatorView to stop animating

I have implemented a non-default animation for when a new view is pushed onto the screen (see code below). For some reason once I implemented this code it caused my UIActivityIndicatorViews to stop working. They will been shown on the screen but not animate even when their isAnimating is true. I figure it is because of me changing the CATransition, but can't figure out how to fix it for the UIActivityIndicatorView.
change default animation for push
CATransition* fade = [CATransition animation];
fade.duration = 1.0;
fade.type = kCATransitionFade;
fade.subtype = kCATransitionFromTop;
[self.navigationController.view.layer
addAnimation:fade forKey:kCATransition];
later on in viewDidLoad I start the animation
[spinner startAnimating];
but the spinner will show and not animate. For some reason the very first spinner I have animates but after that nothing.
I was encountering this problem when using a CATransition inside a subclass of UINavigationController to have a custom animation when pushing or popping view controllers.
Inside a method of this UINavigationController's subclass I had this code:
- (void)addCustomTransition
{
CATransition* transition = [CATransition animation];
transition.duration = kAnimationDuration;
transition.timingFunction =
[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionFade;
[self.view.layer addAnimation:transition forKey:nil];
}
However, I later found out you also have to add the same animation to the pushed/popped viewController's view's layer:
- (void)addCustomTransitionToViewController:(UIViewController *)viewController
{
CATransition* transition = [CATransition animation];
transition.duration = kAnimationDuration;
transition.timingFunction =
[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionFade;
[self.view.layer addAnimation:transition forKey:nil];
[viewController.view.layer addAnimation:transition forKey:nil]; // this is what was missing
}
This pushed/popped view controller's view is that one that had an UIActivityIndicatorView that wasn't animating properly.
Hope this helps!
just change your time duration from 1.0 to 0.3 or less
just i am tested and it's working

Push view controller with custom page curl animation

I want page curl like animation when I push another view. I don't need the default one.
Can I push view with custom animation? I have image sequence.
How can we do that? Help me, please!
You can do this using QuartzCore framwork.
first, #import and before push view controller add this code.
Hope you are OK!
YourViewController *viewControlle = [[YourViewController alloc] init];
CATransition* transition = [CATransition animation];
transition.duration = 1.0;
transition.type = #"pageUnCurl";
transition.subtype = kCATransitionFromRight;
transition.timingFunction = UIViewAnimationCurveEaseInOut;
[self.navigationController.view.layer
addAnimation:transition forKey:kCATransition];
[self.navigationController
pushViewController:viewControlle animated:NO];

transition between 2 UIImages

I use the code below to transition between two UIImageViews.
-(void)performTransitionNew: (NSInteger)type subType:(NSInteger)subType
fromImageView:(UIImageView *)fromImageView
toImageView:(UIImageView *)toImageView duration:(NSInteger)duration;
{
CATransition *transition = [CATransition animation];
transition.duration = duration;//0.3;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
NSString *types[4] = {kCATransitionMoveIn, kCATransitionPush, kCATransitionReveal, kCATransitionFade};
NSString *subtypes[4] = { kCATransitionFromLeft, kCATransitionFromRight, kCATransitionFromTop, kCATransitionFromBottom};
transition.type = types[type];
transition.subtype = subtypes[subType];
transitioning = YES;
transition.delegate = self;
[self.aUIView.layer addAnimation:transition forKey:nil];
fromImageView.hidden = YES;
toImageView.hidden = NO;
UIImageView *tmp = toImageView;
toImageView = fromImageView;
toImageView = tmp;
}
Both of them are on an UIView 'aUIView'.
I want the result to be like this:
but it displays like this:
It looks like toImageView comes from outside of aUIView.
Any comment is welcome.
The Problem is, that the UIView is on top of the other View (were the slider is) You could change the order of these views. If a UIView is in front of another, the Subviews are also, no matter if they are in the bounds of the parent view or not.

Custom UIViewAnimationTransition on iPad

I'm wondering if there is any chance to create a custom transition animation between Views, as a "cube":
http://www.pendrivelinux.com/wp-content/uploads/pdl-cubed.jpg
I've took a look for some example, without any success, do you know some, is even possible?
Thanks
UIViewController* viewCtrl = [[UIViewController alloc] init];
CATransition *transition = [CATransition animation];
transition.duration = 1;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = #"cube"; //Note: undocumented API, will probably cause App Store rejection
transition.subtype = kCATransitionFromLeft;
transition.delegate = self;
[self.navigationController.view.layer addAnimation:transition forKey:nil];
self.navigationController.navigationBarHidden = NO;
[self.navigationController pushViewController:viewCtrl animated:YES];
[viewCtrl release];
It should be possible. You will need to have 2 views and a bit of Core Animation 3D transforms.