【发布时间】:2021-02-18 21:48:18
【问题描述】:
使用动画更改控制器时,我看到背景为黑色。我试图以不同的方式改变它,但没有任何效果。怎么办?
self.view.backgroundColor = [UIColor whiteColor];
self.view.layer.backgroundColor = [UIColor whiteColor].CGColor;
self.view.window.backgroundColor = [UIColor whiteColor];
self.view.window.layer.backgroundColor = [UIColor whiteColor].CGColor;
UIApplication.sharedApplication.windows.firstObject.backgroundColor = [UIColor whiteColor];
[UIApplication sharedApplication].windows.lastObject.rootViewController.view.backgroundColor = [UIColor whiteColor];
[UIApplication sharedApplication].windows.lastObject.rootViewController.view.layer.backgroundColor = [UIColor whiteColor].CGColor;
[UIApplication sharedApplication].windows.firstObject.rootViewController.view.backgroundColor = [UIColor whiteColor];
[UIApplication sharedApplication].windows.firstObject.rootViewController.view.layer.backgroundColor = [UIColor whiteColor].CGColor;
[UIApplication sharedApplication].windows.firstObject.screen.focusedView.backgroundColor = [UIColor whiteColor];
UIScene *scene = [[[[UIApplication sharedApplication] connectedScenes] allObjects] firstObject];
if([scene.delegate conformsToProtocol:@protocol(UIWindowSceneDelegate)]){
UIWindow *window = [(id <UIWindowSceneDelegate>)scene.delegate window];
window.backgroundColor = [UIColor whiteColor];
}
ViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"ViewController2"];
vc.modalPresentationStyle = UIModalPresentationFullScreen;
CATransition* transition = [CATransition animation];
transition.duration = 0.5;
transition.type = kCATransitionMoveIn;
transition.subtype = kCATransitionFromLeft;
[self.view.window.layer addAnimation:transition forKey:kCATransition];
[self presentViewController:vc animated:NO completion:nil];
【问题讨论】:
标签: ios objective-c xcode