I am willing to create a segue animation similar to opening an app in iOS 7. Now I consider this approach: Non-segue implementation, but encountered an issue: if being implemented in custom segue, the code cannot resize viewcontroller's frame, which is principal part of the animation. As I can see, it applies viewcontroller's position, but cannot change it's size. Am I correct, that property viewcontroller.view.frame cannot be animated and has to remain constant and equal to size of the device's screen? I already implemented something similar with CGAffineTransformMakeScale
, but its a bit weird, so, I am looking for better solution. Below I paste the code I use for the segue.
#import "ZoomSegue.h"
#import "MiniMapViewController.h"
#import "InteractiveMapViewController.h"
@implementation ZoomSegue
- (void)perform {
InteractiveMapViewController *sourceViewController = self.sourceViewController;
MiniMapViewController *destinationViewController = self.destinationViewController;
destinationViewController.view.alpha = 0.0f;
destinationViewController.view.hidden = NO;
//Just to check, lets make view really small. Position it to the center we get from the segue.
destinationViewController.view.frame = CGRectMake(_originatingPoint.x, _originatingPoint.y, 60.0f, 60.0f);
[sourceViewController.view addSubview:destinationViewController.view];
float animationDuration = 1.5f;
[UIView animateWithDuration:animationDuration/2.0f animations:^{
destinationViewController.view.alpha = 1.0f;
}];
[UIView animateWithDuration:animationDuration animations:^{
//Just to check, lets make view very big. It does not work, although, the view goes to the upper left corner, so position works, but not the size
CGRect x = CGRectMake(0.0f, 0.0f, 9590.0f, 91366.0f);
destinationViewController.view.frame = x;
}];
}
@end
I've translated the same code in SWIFT.
And this is how you call it:
I don't know if you're correct, but a better way to do it anyway is to use a snapshot view. This code puts a small snapshot in the center of the screen then expands it to full size,
After Edit:
Here is a translation of the code in the link you provided that converts that animation into a segue,
I have a CGRect property, iconFrame in the .h file of the segue. I performed the segue from a tap gesture recognizer that was attached to the icon that will be expanded. You need to pass the frame of that icon to the segue, which I do in the source view controller's prepareForSegue method,