简体   繁体   English

更改UIViewAnimationTransition背后的背景

[英]Change background behind a UIViewAnimationTransition

When animating a transition to another view I am using the following code: 当动画过渡到另一个视图时,我使用以下代码:

[UIView beginAnimations:@"transition" context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft
        forView:self.navigationController.view cache:NO];
[self.navigationController pushViewController:newView animated:NO];
[UIView commitAnimations];

This works fine but during the flip animation there is a solid white background behind the animation. 这可以正常工作,但是在翻转动画期间,动画后面会出现纯白色背景。 I was wondering if anyone knows a simple way to change the color of this background behind the animation. 我想知道是否有人知道一种简单的方法来更改动画背后背景的颜色。 Thanks! 谢谢!

It's should be the backgroundColor of your UIWindow or keyWindow.rootViewController.view . 这应该是backgroundColor你的UIWindowkeyWindow.rootViewController.view

Set the backgroundColor of every view below your animated view to [UIColor blackColor] should solve your problem (don't forget the UIWindow's backgroundColor too). 将动画视图下方的每个视图的backgroundColor设置为[UIColor blackColor]应该可以解决您的问题(也不要忘记UIWindow的backgroundColor)。

I think the solid white background you see behind the animation is just the background color of whatever view is underneath. 我认为您在动画后面看到的纯白色背景就是下面任何视图的背景颜色。 Simply changing the background color of that view ( view.backgroundColor = [UIColor blackColor] or something like that) should change what you see underneath. 只需更改该视图的背景颜色( view.backgroundColor = [UIColor blackColor]或类似的东西)即可更改您在下面看到的内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM