I have a custom segue, trying to replicate the push/pop segues of the pre iOS 7 style:
viewControllers animating SIDE-BY-SIDE, with NO darkening. (Is it really that hard!)
The code below works, except:
the exiting page becomes dark on exit
the entering page is dark on entering (gradually becomes normal as it moves into position)
These images illustrate the problem:
and then...
Is there a way to stop this darkening effect? I would be really grateful for some help.
-(void)perform
{
UIViewController *source = self.sourceViewController;
UIWindow *window = source.view.window;
CATransition *transition = [CATransition animation];
[transition setDuration:2.0];
[transition setDelegate:self];
[transition setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear]];
[transition setType:#"push"];
[transition setSubtype:kCATransitionFromRight];
[window.layer addAnimation:transition forKey:kCATransition];
[window setRootViewController:self.destinationViewController];
}
These 2 functions work fine for me, although the code is pretty similar to yours, I hope it helps.
+(void) modalRight:(UIViewController*)vc destvc:(UIViewController*)viewCtrl{
CATransition *transition = [CATransition animation];
transition.duration = 0.3;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFromRight;
[vc.view.window.layer addAnimation:transition forKey:nil];
[vc presentModalViewController:viewCtrl animated:NO];
}
+(void) modalLeft:(UIViewController*)vc{
CATransition *transition = [CATransition animation];
transition.duration = 0.3;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFromLeft;
[vc.view.window.layer addAnimation:transition forKey:nil];
[vc dismissModalViewControllerAnimated:NO];
}
Related
I am using a CATransition animation in my application and it works fine, but crashes some times.
This is my Code:
-(void)_close_btn_click:(UIButton*)button
{
NSLog(#"update Button %ld clicked.",(long int)[button tag]);
NSInteger intvalue=[[NSString stringWithFormat:#"%ld",(long int)[button tag]]intValue];
NSLog(#"delete_index:%d",intvalue);
CATransition* transition = [CATransition animation];
[transition setDuration:1.0];
transition.type = #"rippleEffect";
transition.subtype = kCATransitionFromLeft;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
[cell._slide_view.layer addAnimation:transition forKey:#"push-transition"];
CATransition* transition1 = [CATransition animation];
[transition1 setDuration:1.0];
transition1.type = #"rippleEffect";
transition1.subtype = kCATransitionFromLeft;
[cell._en_cell_close_btn.layer addAnimation:transition forKey:#"push-transition"];
cell._slide_view.hidden=YES;
}
I guess maybe your cell or _slide_view has been deallocated before you call this method
I have to present a UIImagePickerController but when I do so, it always come from the bottom up. Is there a way to make it appear from the right to left?
I have tried this without success:
CATransition* transition = [CATransition animation];
transition.duration = 0.35f;
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFromLeft;
[self.navigationController.view.layer addAnimation:transition forKey:kCATransition];
[self.navigationController presentModalViewController:picker animated:YES];
thanks
I assume you are currently displaying the picker by calling presentModalViewController:animated: and passing YES as the animated option.
What you can do instead is present without animating, and instead cover the appearance using your own transition animation. The example below would present from the right:
CATransition *transition = [CATransition animation];
transition.duration = 0.5;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionMoveIn;
transition.subtype = kCATransitionFromRight;
[self.view.window.layer addAnimation:transition forKey:nil];
[self presentModalViewController:pickerController animated:NO];
To use this you'll need to #import <QuartzCore/QuartzCore.h> and add the QuartzCore framework to the project.
I am looking to implement CATransitions within TTNavigator, I know the method
openURL can take a UIViewAnimationTransition but that only gives me
flipping and curling animations, but with CATransition I have access
to another 8, of which kCATransitionFromRight, kCATransitionFromLeft,
kCATransitionFromTop, kCATransitionFromBottom are the ones I am
specifically after.
With a UINavigationController would use something like this piece of code to
give me more control over the animation:
CATransition *transition = [CATransition animation];
transition.duration = 0.5f;
transition.timingFunction = [CAMediaTimingFunction
functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
[self.navigationController.view.layer addAnimation:transition
forKey:nil];
This code however, doesn't work with TTNavigator. Does anybody know
how I can get my own custom animations to work with TTNavigator? Or if
I am doing something wrong in my code?
Turns out i answered my own question, but rather than using that last line of code to set the animation on the navigationController i was trying to set the transition to the URLAction. Once i put that line back in and commented out the URLAction transition code it seems to work!
// create the URLAction
TTURLAction* urlAction;
urlAction = [TTURLAction actionWithURLPath:#"tt://Images"];
[urlAction applyAnimated:YES];
// create the CATransition and set it to the navigation controller
CATransition *transition = [CATransition animation];
transition.duration = 0.5f;
transition.timingFunction = [CAMediaTimingFunction
functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
[self.navigationController.view.layer addAnimation:transition
forKey:nil];
// tell the navigator to run the action
[[TTNavigator navigator] openURLAction:urlAction];
Hope this helps someone else in the future!
You can easily add flip or any other kind of animation on TTNavigator using TTLauncherView as follows:
- (void)launcherView:(TTLauncherView*)launcher didSelectItem:(TTLauncherItem*)item {
TTURLAction* action = [TTURLAction actionWithURLPath:item.URL];
[action setAnimated:YES];
[action setTransition:UIViewAnimationTransitionFlipFromLeft];
[[TTNavigator navigator] openURLAction:action];
}
This makes TTNavigator use animated transition while displaying new URL.
First here's my code:
[_helperView addSubview:_navigationController.view];
[_helperView addSubview:itemView];
[UIView beginAnimations:#"pageFlipAnimation" context:nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:_helperView cache:NO];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:#selector(pageFlipAnimationDidStop)];
[itemView removeFromSuperview];
[UIView commitAnimations];
My problem with this that nothing is animated. If I add the _navigationController.view and itemView before (I mean not in this method) everything is ok, but when I add before the animation it does nothing. I also tried to call again the animation in the animation didStopSelector and also works there.
Can you help me please why it doesn't want to work in this case? Any suggestions how to resolve it?
You should probably give the UI the chance to effectuate the addition of itemView. To do this, add a line after addSubview:itemView:
[self performSelector(removeAnim:) withObject:itemView afterDelay:0.01];
and move the animation block to a function
-(void)removeAnim:(UIVieW*)itemView
This should fix the problem.
Use QuartzCore.framework With these animations.
-(void)viewSlideInFromRightToLeft:(UIView *)views
{
CATransition *transition = nil;
transition = [CATransition animation];
transition.duration = 0.5;//kAnimationDuration
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
transition.subtype =kCATransitionFromRight;
transition.delegate = self;
[views.layer addAnimation:transition forKey:nil];
}
-(void)viewSlideInFromLeftToRight:(UIView *)views
{
CATransition *transition = nil;
transition = [CATransition animation];
transition.duration = 0.5;//kAnimationDuration
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
transition.subtype =kCATransitionFromLeft;
transition.delegate = self;
[views.layer addAnimation:transition forKey:nil];
}
-(void)viewSlideInFromTopToBottom:(UIView *)views
{
CATransition *transition = nil;
transition = [CATransition animation];
transition.duration = 0.5;//kAnimationDuration
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
transition.subtype =kCATransitionFromBottom ;
transition.delegate = self;
[views.layer addAnimation:transition forKey:nil];
}
-(void)viewSlideInFromBottomToTop:(UIView *)views
{
CATransition *transition = nil;
transition = [CATransition animation];
transition.duration = 0.5;//kAnimationDuration
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
transition.subtype =kCATransitionFromTop ;
transition.delegate = self;
[views.layer addAnimation:transition forKey:nil];
}
For AnimationType you can use following option:-> kCATransitionMoveIn, kCATransitionPush, kCATransitionReveal, kCATransitionFade
For AnimationSubType you can use following option:-> kCATransitionFromLeft, kCATransitionFromRight, kCATransitionFromTop, kCATransitionFromBottom
Right now when I use [self.navigationController setNavigationBarHidden:NO animated:YES];
The navigation bar flies in from right to left, is there a way to drop it down top to bottom?
Give this a go:
CATransition *transition = [CATransition animation];
transition.duration = kAnimationDuration;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFromTop;
transition.delegate = self;
[self.navigationController.view.layer addAnimation:transition forKey:nil];
self.navigationController.navigationBarHidden = NO;
[self.navigationController pushViewController:tableViewController animated:YES];
Worked great for me.
Source: http://www.iphonedevsdk.com/forum/iphone-sdk-development/25045-navigation-controller-custom-animation.html