当前具有动画效果的模态视图 [英] Present Modal View with Animation Effect

查看:75
本文介绍了当前具有动画效果的模态视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的iPhone App中,我需要显示一个具有透明背景的模式视图,并且该模式视图应与动画一起出现,就像它从视图中心出现一样并且其大小正在增加。

In my iPhone App I need to display a modal view with transparent background and it should appear with animation like it is appearing from center of view and its size is increasing.

类似于绘制某物的iPhone App,当我们单击设置按钮时。

similar like "drawing something" iPhone App when we click on settings button.

我该怎么做?

推荐答案

假设您要显示一个名为aScoreSheet的viewController。尝试在将要进行演示的视图控制器中定义此方法。

Let's say you have a viewController thats called aScoreSheet that you want to present. Try to define this method in the view controller that's going to do the presenting.

-(void) presentTransparentModalViewController: (ScoreSheet *) aViewController 
{

    scoreSheet = aViewController;
    UIView *view = aViewController.view;

view.opaque = NO;
[view.subviews enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
    UIView *each = obj;
    each.opaque = NO;
}];
    [self.view addSubview:view];

    view.center = CGPointMake(160, 800); //for iPhone

    [UIView animateWithDuration:0.9 delay:0 options:UIViewAnimationCurveEaseInOut animations:^{
         view.center = CGPointMake(160, 240);
    } completion:^(BOOL finished) {

        self.view.userInteractionEnabled=YES;
    }];

}

然后解雇控制器:

-(void) dismissTransparentModalViewControllerAnimated:(BOOL) animated{

if (animated) {

    [UIView animateWithDuration:0.4
                     animations:^{
                         scoreSheet.view.center = CGPointMake(scoreSheet.view.center.x, scoreSheet.view.center.y + 480);
                     } completion:^(BOOL finished) {
                         [scoreSheet.view removeFromSuperview];
                         scoreSheet = nil;
                     }];
}


}

这篇关于当前具有动画效果的模态视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆