View image in fullscreen transition same as Facebook app in IOS - ios

I want to make the transition when touch on image to open the fullscreen same as Facebook app. When user touch on image, the transition is push down image to center, user touch on image again, it will back to previous page. How can i do that? For now, I have 1 viewcontroller contains the imageview in center. I used the code below to make animation when push viewcontroller but it seems not correct.
This is my code :
CATransition* transition = [CATransition animation];
transition.duration = 0.5;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionFromTop; //kCATransitionMoveIn; //, kCATransitionPush, kCATransitionReveal, kCATransitionFade
//transition.subtype = kCATransitionFromTop; //kCATransitionFromLeft, kCATransitionFromRight, kCATransitionFromTop, kCATransitionFromBottom
[self.navigationController.view.layer addAnimation:transition forKey:nil];
[self.navigationController pushViewController:imageView animated:NO];
Please give me some advices. Thanks.

Related

Xcode Segue View Controller Right to left without UINavigation

I want to transition my View Controller Right to Left (just like a Navigation Controller does IT) BUT without a UINavigationController embedded. I'm using Xcode 7 and the standard Segue seems to not have this option. Any guidance is VERY much welcome!!!
If you want to be a hack, you can do this:
CATransition *transition = [CATransition animation];
transition.duration = 0.3;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFromRight;
[self.view.window.layer addAnimation:transition forKey:nil];
[self presentModalViewController:viewCtrl animated:NO];
You should really just use a navigation controller or write a custom transition animation see here for a project that does the animation you want.
let transition = CATransition()
transition.duration = 0.3
transition.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
transition.type = kCATransitionPush
transition.subtype = kCATransitionFromRight
self.view.window?.layer.addAnimation(transition,forKey:nil)
self.presentViewController(viewCtrl, animated: false, completion: nil)
if you need it in Swift.

UINavigationBar fades when pushing/popping

I am using the old (pre-iOS7) push/pop animation by using the method described here:
#implementation UINavigationController (Retro)
- (void)pushViewControllerRetro:(UIViewController *)viewController {
CATransition *transition = [CATransition animation];
transition.duration = 0.25;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFromRight;
[self.view.layer addAnimation:transition forKey:nil];
[self pushViewController:viewController animated:NO];
}
- (void)popViewControllerRetro {
CATransition *transition = [CATransition animation];
transition.duration = 0.25;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFromLeft;
[self.view.layer addAnimation:transition forKey:nil];
[self popViewControllerAnimated:NO];
}
#end
My problem is that iOS7 seems to fade the UINavigationBar of the previous view controller when pushing a new view controller. Normally this looks fine because iOS 7 is dragging the views on top of each other. But when I am using the pre-iOS7 animation it gives me a short flash, because the navigation bar fades while the new view it getting pushed in from the right side.
Is there a way to disable the fade animation on the navigation bar?

Unable to change the popviewcontrolleranimation

I am trying to change the navigationController push and pop animation like presentModalView and dismissModalView animation.
I am successfully change the push view animation by using the below code. For changing push animation is working fine. This code is shows the view from bottom to top animation(for push view).
CATransition *transition = [CATransition animation];
transition.duration = 0.4f;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];
transition.type = kCATransitionMoveIn;
transition.subtype = kCATransitionFromTop;
[self.navigationController.view.layer addAnimation:transition forKey:nil];
[self.navigationController pushViewController:locationObj animated:NO];
But When I am trying to change the pop view animation by using the below code. I am unable to get the top to bottom animation(for pop view).
CATransition *transition = [CATransition animation];
transition.duration = 0.4f;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
[self.navigationController.view.layer addAnimation:transition forKey:nil];
[self.navigationController popViewControllerAnimated:NO];
Please can some one help me.
Tested Code:
CATransition *transition = [CATransition animation];
transition.duration = 0.4f;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
//Pop Animation
transition.type = kCATransitionReveal;
transition.subtype = kCATransitionFromBottom;
[self.navigationController.view.layer addAnimation:transition forKey:nil];
[self.navigationController popViewControllerAnimated:NO];
//Push Animation
//transition.type = kCATransitionMoveIn;
//transition.subtype = kCATransitionFromTop;
//[self.navigationController.view.layer addAnimation:transition forKey:nil];
//[self.navigationController pushViewController:viewControllerToBePushed animated:NO];

how to implement popover controller in storyboard, custom segue

This is mouli, I'm implementing a custom segue for pushing (with animation) from firstview to second view, its work fine. but iam not getting back from secondview to firstview with same animation. Here the first screen appears with out animation. please give some suggestion. Thanks in advance. following is my code for push from first to second.
UIViewController *sourceViewController = [UIApplication sharedApplication].delegate.window.rootViewController;
NSLog(#"%#",sourceViewController);
sourceViewController.modalPresentationStyle = UIModalPresentationCurrentContext;
UIViewController *destinationController = (UIViewController*)[self destinationViewController];
NSLog(#"%#",destinationController);
CATransition* transition = [CATransition animation];
transition.duration = 0.6;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush; //kCATransitionMoveIn; //, kCATransitionPush, kCATransitionReveal, kCATransitionFade
transition.subtype = kCATransitionFromRight; //kCATransitionFromLeft, kCATransitionFromRight, kCATransitionFromTop, kCATransitionFromBottom
[destinationController.view.layer addAnimation:transition forKey:kCATransition];
[sourceViewController presentViewController:destinationController animated:NO completion:nil];
Do the dismiss in opposite way, since your are doing a custom animation other that the provided one, it doesn't remember the animation of presentation. So while you are dismissing you need to apply the opposite custom animation too.
I would suggest you to create a Category for animations and use them in the whole project easily..

Multiple fades in a CATTransition

I'm using a CATransition to create a fade effect on the pushViewControllerAnimated of a UINavigationViewController. This worked out fine with the following code:
CATransition* transition = [CATransition animation];
transition.duration = 0.5;
transition.type = kCATransitionFade;
transition.subtype = kCATransitionFromTop;
[navController.view.layer addAnimation:transition forKey:kCATransition];
[navController popViewControllerAnimated:NO];
[navController pushViewController:nieuweDetailPagina animated:NO];
But because my views are very similar I would like to fade to white in between or show a white flash.
Is it posible to do it in the same transition or do I have to creat a UIView with a white background and start a simultanious animation?
Cheers!

Resources