视图过渡动画

发布于 2024-11-08 19:58:04 字数 807 浏览 0 评论 0原文

我有这样的代码:

- (void) displayView:(int)intNewView{

NSLog(@"%i", intNewView);
[currentView.view removeFromSuperview];
[currentView release];

switch (intNewView) {
    case 1:
        currentView = [[EnterView alloc] init];
        break;
    case 2:
        currentView = [[MainMenuView alloc] init];
        break;
    case 3:
        currentView = [[DetailsView alloc] init];
        break;
    case 4:
        currentView = [[PhotosView alloc] init];
        break;
    case 5:
        currentView = [[CustomUITableViewViewController alloc] init];
        break;
}

[self.view addSubview:currentView.view]; 

}

这段代码成功地转换了视图,但是它并不像您想象的那么壮观(视图只是简单地切换而没有动画)。我想知道是否有一种简单的方法可以在这里添加任何类型的简单视图过渡动画?我不知道如何实现我在网上找到的任何示例。任何动画就足够了,只是一些让事情变得有趣的东西:)

谢谢,

杰克

I have this code:

- (void) displayView:(int)intNewView{

NSLog(@"%i", intNewView);
[currentView.view removeFromSuperview];
[currentView release];

switch (intNewView) {
    case 1:
        currentView = [[EnterView alloc] init];
        break;
    case 2:
        currentView = [[MainMenuView alloc] init];
        break;
    case 3:
        currentView = [[DetailsView alloc] init];
        break;
    case 4:
        currentView = [[PhotosView alloc] init];
        break;
    case 5:
        currentView = [[CustomUITableViewViewController alloc] init];
        break;
}

[self.view addSubview:currentView.view]; 

}

This code successfully transitions views, however its not very spectacular as you can imagine (the view simply switches with no animation). I'm wondering if there is a simple way to add any kind of simple view transition animation here? I can't figure out how to implement any of the example I've found online. Any animation would suffice, just something to spice things up a bit :)

Thanks,

Jack

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

生生不灭 2024-11-15 19:58:04

您可以简单地使用基本的核心动画:

像这样:

[UIView beginAnimations:nil context:nil];

[UIView setAnimationDuration:2];

[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft  forView:self.view cache:YES];


[self.view addSubview:currentView.view];

[UIView commitAnimations];

您可以尝试不同的 UIViewAnimationTransitions,对于“forView”,您输入当前屏幕上的视图。希望有帮助。

You can simply use basic core animations:

Like this:

[UIView beginAnimations:nil context:nil];

[UIView setAnimationDuration:2];

[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft  forView:self.view cache:YES];


[self.view addSubview:currentView.view];

[UIView commitAnimations];

You can try different UIViewAnimationTransitions, for the "forView" you enter the view that currently is on the screen. Hope that helped.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文