iOS15导航栏适配的问题

if (@available(iOS 15.0,*) ) {

        UINavigationBarAppearance *apperance = [[UINavigationBarAppearance alloc]init];

        [apperance configureWithOpaqueBackground];// 重置背景和阴影颜色

        apperance.backgroundColor = [UIColor whiteColor];

        apperance.backgroundEffect = nil;

        // 去除导航栏阴影(如果不设置clear,导航栏底下会有一条阴影线)

       apperance.shadowColor =  [UIColor clearColor];

        [apperance setShadowImage:[UIImage qmui_imageWithColor:[UIColor clearColor]]];

        [apperance setTitleTextAttributes:textAttributes];

        [[UINavigationBar appearance]setStandardAppearance:apperance];

       [[UINavigationBar appearance]setScrollEdgeAppearance:apperance];

    }else{

       

        [[UINavigationBar appearance] setTitleTextAttributes:textAttributes];

        [[UINavigationBar appearance] setBarTintColor:[UIColor whiteColor]];

        [[UINavigationBar appearance] setShadowImage:[UIImage new]];

       

    }

    [[UINavigationBar appearance] setTranslucent:NO];

猜你喜欢

转载自blog.csdn.net/ForeverMyheart/article/details/121541904