1

我有一个 Iphone 应用程序,我想在我的 splashview 中实现一个翻转动画,就像在 PATH 应用程序中一样。我正在使用一个单独的视图控制器来展示我的 splashview。我想用这个动画从窗口中删除它。任何人都可以关于如何实现这一点的想法。这就是我添加视图的方法。我如何从窗口中删除这个视图并添加带有类似动画的新视图

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

    self.startupController = [[StartupViewController alloc] initWithNibName:@"StartupViewController" bundle:nil];
    [window addSubview:self.startupController.view];
    [self.startupController.activityIndicator setHidden:NO];
    [self.startupController.activityIndicator startAnimating];
    [window makeKeyAndVisible];

    timer = [NSTimer scheduledTimerWithTimeInterval: 2.0
                                                 target: self
                                               selector: @selector(handleTimer:)
                                               userInfo: nil
                                                repeats: NO];


    // [window addSubview:navigationController.view];
    //  [window makeKeyAndVisible];

    return YES;
}

-(void)handleTimer:(NSTimer*)timer {


    [self.startupController.activityIndicator stopAnimating];
    [self.startupController.activityIndicator setHidden:YES];

    self.startupController.view.layer.anchorPoint=CGPointMake(0, .5);
    self.startupController.view.center = CGPointMake(self.startupController.view.center.x - self.startupController.view.bounds.size.width/2.0f, self.startupController.view.center.y);
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:5];
    [UIView setAnimationDelay:1];
    self.startupController.view.transform = CGAffineTransformMakeTranslation(0,0);
    CATransform3D _3Dt = CATransform3DIdentity;
    _3Dt =CATransform3DMakeRotation(3.141f/2.0f,0.0f,-1.0f,0.0f);
    _3Dt.m34 = 0.001f;
    _3Dt.m14 = -0.0015f;
    self.startupController.view.layer.transform =_3Dt;
    [UIView commitAnimations];  
    //[window addSubview:navigationController.view];
     //[window makeKeyAndVisible];      
}

`when i am doing like this i can have that flip animation.but when the view is flipping i need to have my home view there.But when i am uncomenting the last two lines that functionality is working but there is no animation.Can anybody help me?
4

2 回答 2

1

这是我已经在我的一个项目中使用的代码。

我需要像垫子一样打开封面。

#pragma mark Open Book Animation

- (void)pageOpenView:(UIView *)viewToOpen duration:(NSTimeInterval)duration {

  // first add next view below current view
  [self.view.window insertSubview:navigationController.view 
                     belowSubview:self.view];

  // set anchor point for the view animation
  viewToOpen.layer.anchorPoint = CGPointMake(0.0f, 0.0f);

  viewToOpen.center = CGPointMake(0, 
                                  (viewToOpen.center.y - 
                                   (viewToOpen.bounds.size.height/2.0f)));

  // start the Page Open
  [UIView beginAnimations:@"Page Open" context:nil];
  [UIView setAnimationDuration:2.0];
  [UIView setAnimationDelegate:self];
  [UIView setAnimationDidStopSelector:@selector(didEndAnimation)];

  [viewToOpen.layer setValue:[NSNumber numberWithInt:180] 
                  forKeyPath:@"transform.rotation.x"];

  [splashImageView setHidden:YES];

  [UIView commitAnimations];

}

这里viewToOpen是需要动画的UIView,duration是动画的时间线。

希望这是您所需要的。

享受编码:)

于 2012-07-24T10:06:00.137 回答
1

我喜欢这篇文章中使用的方法。虽然那里使用的动画是褪色的,但它是动画的一个很好的容器。

如果你还设置了animationTransition,你应该可以得到你想要的动画。像这样的东西。。

[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:splashView cache:YES];

这至少应该让你开始。:-)

于 2012-07-24T09:08:54.030 回答