问题
I'm trying to implement custom view presenting transition style. Here is my code:
[myViewController setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];
[self presentViewController:myViewController animated:YES completion:^(void){}];
I'd like to achieve “scale from center” effect while presenting views. I made a demo of desired effect with JQuery UI: http://jsfiddle.net/c7ztP/
Is there any way to do this?
回答1:
What I would do is the following
From the initiating view controller i would do this
// OriginalViewController.h
newViewcontroller.view.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.0f, 0.0f);
[self presentViewController:newViewController animated:NO completion:nil];
And on the receiving view controller I would do this
-(void)viewDidLoad {
[UIView animateWithDuration:0.3f animations:^{
self.view.transform = CGAffineTransformScale(CGAffineTransformIdentity, 1.0f, 1,0f);
}];
}
For this to work you'll need QuartzCore.framework
. Also to make it sweeter I would add zero alpha to full alpha animated as it looks better.
回答2:
You should write your own Controller with this animation effect.
Look at this controls: KGModal and UAModalPanel.
Check theirs source code for animation example. It's not difficult to rewrite this code to support fullscreen view.
来源:https://stackoverflow.com/questions/15809727/presentviewcontroller-with-custom-scale-from-center-modaltransitionstyle