Color change behind application while rotating

When the iOS application rotates, it will show a black background when the application is between the portrait and the landscape. Can I change this color from default black to white? Changing the background color of a UIWindow will not help. Here is an example of a black background in Safari during rotation: Safari rotation

+4
source share
4 answers

I did something similar, but now I could not find the source, but here is the idea:

Create and add a significantly larger view as a rear view and center it.

Add UIWebViewas a spy this large view whose background is white.

Move the center again UIWebView.

+4
source

You can do this: enter image description here

UIViewController VC ( MainVC).
UIViewContainer: , vcs.
viewDidLayoutSubviews VC ( .m VC)

- (void)viewDidLayoutSubviews
{
    [super viewDidLayoutSubviews];

    //Some hardcode :)
    self.view.frame = CGRectMake(-100, -100, 1136, 1136);
}

- :

enter image description here

, , , .

+4

, viewController :

CGFloat length = 2*MAX(rootViewController.view.bounds.size.height, rootViewController.view.bounds.size.width);

UIView *oversizedBackgroundView = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, length, length)];
oversizedBackgroundView.center = vc.view.center;
oversizedBackgroundView.backgroundColor = [UIColor whiteColor];
rootViewController.view.clipsToBounds = NO;
[rootViewController.view addSubview:oversizedBackgroundView];
[rootViewController.view sendSubviewToBack:oversizedBackgroundView];

self.window.rootViewController = rootViewController;
[self.window makeKeyAndVisible];

clipsToBounds NO

0

I have the same problem. As far as I understand, you want to remove the black background. The easiest solution I've used is to set clipToBounds = true for windows instead of your rootViewController.

window?.clipsToBounds = true
0
source

Source: https://habr.com/ru/post/1531942/


All Articles