【问题标题】:iPhone: How to set animation style for UIView?iPhone:如何为 UIView 设置动画样式?
【发布时间】:2011-02-28 09:55:06
【问题描述】:

我使用以下代码为页面设置动画。

    [UIView a animateWithDuration:0.3
                 animations:^{
                    text.alpha=0;
                 } completion:^(BOOL finished) {
                    //some code
                 }];

现在我想使用一些动画样式(卷曲波纹等)更改视图。我该怎么做?

【问题讨论】:

    标签: iphone animation


    【解决方案1】:
            [UIView transitionWithView:superView duration:1.0
                           options:UIViewAnimationOptionTransitionCurlUp
                        animations:^{
                            [self.view removeFromSuperview];
                            [superView addSubview:newView];
                        }
                        completion:NULL];
    

    【讨论】:

      【解决方案2】:

      您可能需要设置动画过渡:
      [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration: 1.0]; [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.view cache:NO]; //your code [UIView commitAnimations];

      【讨论】:

      • 不,我不想使用这个,因为这样对多个动画进行排序变得很困难。
      • 你能解释一下你想要什么吗?
      【解决方案3】:

      //直接试试uiview或者在ui viewcontroller中把uiview改成你的view

          [UIView beginAnimations:nil context:NULL];
          [UIView setAnimationDuration:1.0];
          [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self cache:YES];
          [UIView commitAnimations];
      

      【讨论】:

        【解决方案4】:

        我已经更正它以替代 superview:

        [UIView transitionWithView:self.parentViewController.view duration:1.0
                                   options:UIViewAnimationOptionTransitionCurlUp
                                animations:^{
                                    [self.view removeFromSuperview];
                                    [self.parentViewController.view addSubview:self.newVC.view];
                                }
                                completion:NULL];
        

        【讨论】:

          猜你喜欢
          • 2014-08-31
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2022-01-22
          • 2017-02-12
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多