1. The navigationbar become transparent

Solutions:


@implementation** UINavigationController (Extension)
/// Change to color
- (void)changeBackgroundColor:(UIColor *)color {
    static UIImage *backgroundImage = nil;
    static UIImage *shadowImage = nil;
    if(! backgroundImage) { backgroundImage = [LGImage imageWithColor:color]; shadowImage = [LGImage imageWithColor:[UIColor clearColor]];
    }
    
    if (@available(iOS 13.0, *)) { 
        // Use this after iOS13
        UINavigationBarAppearance *apparance = [[UINavigationBarAppearance alloc] init];
        [apparance configureWithOpaqueBackground];
        apparance.backgroundColor = color;
        [apparance setShadowImage:shadowImage];
        self.navigationBar.standardAppearance = apparance;
        self.navigationBar.scrollEdgeAppearance = self.navigationBar.standardAppearance;

    } else {
    // Invalid after iOS15
        [self.navigationBar setBackgroundImage:backgroundImage forBarMetrics:UIBarMetricsDefault];
        [self.navigationBar setShadowImage:shadowImage]; }}/// Change to a picture
- (void)changeBackgroundImage:(UIImage *)image {
  
    static UIImage *shadowImage = nil;
    if(! shadowImage) { shadowImage = [LGImage imageWithColor:[UIColor clearColor]];
    }
    
    if (@available(iOS 13.0, *)) {
        UINavigationBarAppearance *apparance = [[UINavigationBarAppearance alloc] init];
        [apparance configureWithOpaqueBackground];
        apparance.backgroundColor = [UIColor clearColor];
        [apparance setShadowImage:shadowImage];
        self.navigationBar.standardAppearance = apparance;
        [self.navigationBar setBackgroundImage:image forBarMetrics:UIBarMetricsDefault];
        self.navigationBar.scrollEdgeAppearance = self.navigationBar.standardAppearance;

    } else{[self.navigationBar setBackgroundImage:image forBarMetrics:UIBarMetricsDefault];
        [self.navigationBar setShadowImage:shadowImage]; }}@end

Copy the code

2. The tabbar become transparent


- (void)changeBackgroundColor:(UIColor *)color{
    if (@available(iOS 15.0, *)) { // Add new class to change tabbar after iOS15, use this to change background color
        UITabBarAppearance *appearance = [[UITabBarAppearance alloc] init];
        [appearance configureWithOpaqueBackground];
        appearance.backgroundColor = color;
        self.tabBar.standardAppearance = appearance;
        self.tabBar.scrollEdgeAppearance = appearance; }}Copy the code

3. Iphone13 mini top security zone changes need to be noted