【问题标题】:Custom Animations with UIViewController使用 UIViewController 自定义动画
【发布时间】:2012-04-16 20:26:24
【问题描述】:

我正在使用自定义动画来展示我的视图控制器。代码如下:

-(void)launchCustomModal:(id)sender
{
    UIButton *buttonClicked = (UIButton *)sender;
    int selection;
    selection = buttonClicked.tag;
    [ticker removeFromSuperview];
    ticker = nil;

    if (selection == 3)
    {
        MyViewController *myVC = [[MyViewController alloc]initWithNibName:nil bundle:nil];
        modalViewController= [[UINavigationController alloc]initWithRootViewController:myVC];
        modalViewController.navigationBarHidden = YES;
        [modalViewController setToolbarHidden:YES];

        CGRect result = self.view.bounds;
        result.origin.y = -result.size.height;
        modalViewController.view.frame=result;
        [self.view addSubview:modalViewController.view];

        [UIView animateWithDuration:.375 
                         animations:^{ 
                             modalViewController.view.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
                         }
                         completion:^(BOOL finished) {
                             NSLog(@"Finished");          
                         }];
    }

    return;
}

我注意到这种方法会导致过渡非常缓慢。如果我以正常模式启动 VC,它工作得非常顺利。此外,如果我只为独立于视图控制器的视图设置动画,它也可以非常顺利地工作。我想知道是否有关于 VC 的某些东西可能导致它的动画效果如此糟糕?如果它是我正在做的事情的症状,或者视图控制器不应该以这种方式处理,等等。任何输入都非常感谢。谢谢!

【问题讨论】:

  • 已修复!我从 MyViewController 中删除了一个阴影,现在效果很好。猜猜这些很难渲染
  • 是的,阴影每次都会这样做。我像躲避瘟疫一样避开它们。
  • 请将您的解决方案添加为正确的答案,这样以后的读者更容易看到您找到了解决方案:-)

标签: ios xcode quartz-graphics modalviewcontroller


【解决方案1】:

这是 CALayer 阴影。删除它们,它工作正常。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-11-27
    • 2017-06-20
    • 1970-01-01
    • 1970-01-01
    • 2014-11-19
    • 2015-09-30
    • 1970-01-01
    相关资源
    最近更新 更多