iOS:Compat with iOS 15

This commit is contained in:
pengfei.zhou 2021-09-28 15:47:22 +08:00 committed by osborn
parent 63e0d1c38c
commit ea4f6a4f08
3 changed files with 18 additions and 0 deletions

View File

@ -25,6 +25,12 @@ - (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session op
doricViewController.navigationItem.rightBarButtonItem = rightBarItem; doricViewController.navigationItem.rightBarButtonItem = rightBarItem;
#endif #endif
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:doricViewController]; UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:doricViewController];
UINavigationBar *bar = navigationController.navigationBar;
if (@available(iOS 15.0, *)) {
UINavigationBarAppearance *barAppearance = [UINavigationBarAppearance new];
barAppearance.backgroundColor = UIColor.whiteColor;
bar.scrollEdgeAppearance = bar.standardAppearance = barAppearance;
}
UIWindow *window = [[UIWindow alloc] initWithWindowScene:windowScene]; UIWindow *window = [[UIWindow alloc] initWithWindowScene:windowScene];
window.frame = windowScene.coordinateSpace.bounds; window.frame = windowScene.coordinateSpace.bounds;
window.rootViewController = navigationController; window.rootViewController = navigationController;

View File

@ -23,6 +23,12 @@ - (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session op
doricViewController.navigationItem.rightBarButtonItem = rightBarItem; doricViewController.navigationItem.rightBarButtonItem = rightBarItem;
#endif #endif
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:doricViewController]; UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:doricViewController];
UINavigationBar *bar = navigationController.navigationBar;
if (@available(iOS 15.0, *)) {
UINavigationBarAppearance *barAppearance = [UINavigationBarAppearance new];
barAppearance.backgroundColor = UIColor.whiteColor;
bar.scrollEdgeAppearance = bar.standardAppearance = barAppearance;
}
UIWindow *window = [[UIWindow alloc] initWithWindowScene:windowScene]; UIWindow *window = [[UIWindow alloc] initWithWindowScene:windowScene];
window.frame = windowScene.coordinateSpace.bounds; window.frame = windowScene.coordinateSpace.bounds;
window.rootViewController = navigationController; window.rootViewController = navigationController;

View File

@ -47,6 +47,12 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
#if __has_include(<SDWebImage/SDWebImage.h>) #if __has_include(<SDWebImage/SDWebImage.h>)
[SDImageCodersManager.sharedManager addCoder:SDImageWebPCoder.sharedCoder]; [SDImageCodersManager.sharedManager addCoder:SDImageWebPCoder.sharedCoder];
#endif #endif
UINavigationBar *bar = self.navigationController.navigationBar;
if (@available(iOS 15.0, *)) {
UINavigationBarAppearance *barAppearance = [UINavigationBarAppearance new];
barAppearance.backgroundColor = UIColor.whiteColor;
bar.scrollEdgeAppearance = bar.standardAppearance = barAppearance;
}
return YES; return YES;
} }