从延迟向右翻转

时间:2015-07-21 08:27:19

标签: ios objective-c uiviewanimationtransition

我想在我的应用中添加动画。我有一张卡片,我想将它移动到中心,然后卡片从右边翻转。我用过这段代码;

 [self.scrollView bringSubviewToFront:self.image1];
    CATransition *animation = [CATransition animation];
    animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    animation.type = kCATransitionFade;
    animation.duration = 0.75;
    [self.image1.layer addAnimation:animation forKey:@"kCATransitionFade"];
    [UIView animateWithDuration:0.5 animations:^{
        self.image1.frame = CGRectMake(90,self.scrollView.frame.origin.y+40, 140, 250);
    }];
    self.image1.transform = CGAffineTransformMakeScale(0.1,0.1);

    [self.view bringSubviewToFront:self.image1];
    [UIView beginAnimations:@"fadeInNewView" context:NULL];
    [UIView setAnimationDuration:1.0];
    self.image1.transform = CGAffineTransformMakeScale(2,2);
    self.image1.alpha = 1.0f;
    [UIView commitAnimations];
    UIImage *imageTest=[UIImage imageNamed:@"home.png"];


    [UIView transitionWithView:self.image1 duration:1
                       options:UIViewAnimationOptionTransitionFlipFromRight animations:^{
                           self.image1.image = imageTest;
                       } completion:nil];

但是卡片在转到新框架之前是翻转的。任何想法我如何解决这个>

2 个答案:

答案 0 :(得分:0)

你必须制作一系列动画。最简单的方法是将翻转动画放在帧更改动画的完成块中。

示例:

[UIView animateWithDuration:0.5 
                 animations:^{
                     self.image1.frame = CGRectMake(90,self.scrollView.frame.origin.y+40, 140, 250);
                 }
                 completion:^(BOOL finished){ 
                     //your flip animation goes here
                 }];

答案 1 :(得分:0)

使用此代码。可能会帮助你从右侧翻转动画。

[UIView transitionFromView:appDelegate.window.rootViewController.view
                            toView:appDelegate.navigationController.view
                          duration:0.5
                           options:UIViewAnimationOptionTransitionFlipFromRight
                        completion:^(BOOL finished)
         {
             [appDelegate.window setRootViewController:appDelegate.navigationController];
         }];