如何在iPhone翻转视图动画过渡期间控制背景颜色? [英] How do I control the background color during the iPhone flip view animation transition?

查看:138
本文介绍了如何在iPhone翻转视图动画过渡期间控制背景颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些相当标准的翻转动作:

I have some pretty standard flipping action going on:

[UIView beginAnimations:@"swapScreens" context:nil];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.view cache:YES];
[UIView setAnimationDuration:1.0];
[self.view exchangeSubviewAtIndex:0 withSubviewAtIndex:1];
[UIView commitAnimations]; 

对Apple来说,这种动画风格非常容易使用。非常酷,我已经能够非常轻松地在整个应用程序中设置过渡,翻转,淡入等动画。

To Apple's credit, this style of animation is amazingly easy to work with. Very cool, and I've been able to animate transitions, flips, fades etc. throughout the app very easily.

问题:期间翻转过渡,翻转过程中两个视图后面可见的背景是白色的,我希望它是黑色的。我已经:

Question: During the flip transition, the background visible 'behind' the two views during the flip is white and I'd like it to be black. I've:


  • 设置包含视图的背景( self.view 以上) - 没有骰子。我真的认为这样可行。

  • 将每个视图的背景设置为黑色 - 没有骰子。我不认为这会起作用,虽然你给出了不同的东西以便更好地理解:)

  • Google就像疯了似的;继续登陆与Safari相关的列表。

  • Set the background of the containing view (self.view above) - no dice. I really thought that would work.
  • Set the background of each view to black - no dice. I didn't think this would work although you give different things a shot to understand better :)
  • Google'd like crazy; keep landing on Safari-related listings.

提前致谢!

推荐答案

您可以使用颜色或图像。您可以添加视图来执行此操作:

You could use a color or an image. You can add a view to do it:

UIWindow *window = [appDelegate window];
UIView *bgView = [[UIView alloc] init];
[bgView setBackgroundColor:[UIColor blackColor]];
[window addSubView:bgView];

或直接在窗口上设置背景颜色:

Or set the background color on the window directly:

[[appDelegate window] setBackgroundColor:[UIColor blackColor]];

这篇关于如何在iPhone翻转视图动画过渡期间控制背景颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆