Black background when view rotates on orientation

2019-07-21 10:11发布

问题:

I am fiddling with an orientation change responsive app in Xcode and am trying to figure out how I can change that my non-black view seems to rotate on a black background on orientation change!

It looks something like this:

I would like to change the black background to the colour of my view - which is pink in the depicted case.

When my app launches it also shows a black screen until the actual view appears. I have the feeling that it is the same black that becomes visible on orientation change?

I have tried to change the background colour of the window in the did-finish-launching method of my app delegate, but that did not have any effect:

- (BOOL) application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    self.window.backgroundColor = [UIColor purpleColor];

    ...
}

Any suggestions?

回答1:

Try using willAnimateRotationToInterfaceOrientation:duration: method instead of willRotateToInterfaceOrientation:duration:

But I think nearly all of the apps in iOS show a glimpse of black background, it seems normal. In your case if it is for long time, try reducing the duration time.

Also check this Stackoverflow Post