PresentViewController with custom “scale-from-center” ModalTransitionStyle

£可爱£侵袭症+ 提交于 2019-12-08 02:41:50

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!