How do I control the background color during the iPhone flip view animation transition?

亡梦爱人 提交于 2019-12-03 16:16:57

问题


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]; 

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:

  • 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.

Thanks in advance!


回答1:


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]];



回答2:


You can also set the background color on the Window in MainWindow.xib in IB if that's easier.



来源:https://stackoverflow.com/questions/2899211/how-do-i-control-the-background-color-during-the-iphone-flip-view-animation-tran

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!