几秒钟后翻转iPhone视图控制器以显示数据更改



我想在单击按钮时翻转视图动画,以便我可以在同一视图控制器上更改文本和图像,并且可以在我的iPhone应用程序中提供很酷的动画。我已经将这段代码用于翻转过渡:-

[self.navigationController pushViewController: viewControllerName animated:NO]; 
[UIView setAnimationDuration: 0.7];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.navigationController.view    cache:NO]; 
[UIView commitAnimations];

但它会推送我不想要的新视图控制器。 我想在同一视图上翻转此动画

请帮忙。

你试过[yourViewController.view setNeedsDisplay]吗?

这就是你所需要的。这将翻转您的视图,而无需第二个视图。它提供了在动画期间和之后进行更改的地方。

[UIView transitionWithView:MYVIEW duration:0.7 options:UIViewAnimationOptionTransitionFlipFromRight animations:^{
    // Make your changes to the view here.
} completion:^(BOOL finished) {
    // Do any cleanup necessary here.
}];

你可以试试这个代码...这对我来说很好。

flipView=[[FlipMyGuideViewController alloc]init];
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:1.0];
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft
                           forView:[self view]
                             cache:YES];

    [self.view addSubview:flipView.view];

    [UIView commitAnimations];

最新更新