PresentViewController with custom “scale-from-cent

2019-05-21 11:56发布

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?

2条回答
Juvenile、少年°
2楼-- · 2019-05-21 12:52

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.

查看更多
贼婆χ
3楼-- · 2019-05-21 12:55

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.

查看更多
登录 后发表回答