【问题标题】:Transition of a view with a slide? [duplicate]用幻灯片转换视图? [复制]
【发布时间】:2015-02-16 19:21:10
【问题描述】:

我想这已经被问过,但我找不到答案。 当我替换视图时,我希望第一个视图将从左向右滑动(如滚动视图)。 但是UIViewAnimationOptionTransition中没有这个选项

    UIViewController *mainV=[self.storyboard instantiateViewControllerWithIdentifier:@"CallTestView"];
    AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
     [UIView transitionFromView:delegate.window.rootViewController.view
                        toView:mainV.view
                      duration:1.75f
                       options:UIViewAnimationOptionTransitionFlipFromLeft
                    completion:^(BOOL finished)
     {
         delegate.window.rootViewController=mainV;


     }];

【问题讨论】:

    标签: ios objective-c


    【解决方案1】:

    试试这个方法

    [UIView animateWithDuration:0.5
                          delay:0.0
                        options:UIViewAnimationOptionCurveEaseInOut
                     animations:^{
    
    
    
                     }
                     completion:^(BOOL finished){
    
    
                     }];
    

    【讨论】:

      【解决方案2】:

      您可以通过以下方式实现它:

      CATransition *transitionAnimation = [CATransition animation];
      [transitionAnimation setType:kCATransitionPush];
      [transitionAnimation setSubtype:kCATransitionFromRight];
      [transitionAnimation setDuration:0.5f];
      [transitionAnimation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
      [transitionAnimation setFillMode:kCAFillModeBoth];
      
      [youView.layer addAnimation:transitionAnimation forKey:@"changeTextTransition"];
      

      你可以根据自己的需要在setSubType中替换或改变方向。

      【讨论】:

        猜你喜欢
        • 2013-01-23
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-05-12
        • 1970-01-01
        • 1970-01-01
        • 2022-12-21
        • 1970-01-01
        相关资源
        最近更新 更多