iOS 导航栏返回把样式带回前面怎么办
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | //设置当前页面导航栏 - ( void )viewWillAppear:( BOOL )animated { [ super viewWillAppear:animated]; // 让导航栏背景透明 self .navigationController.navigationBar.tintColor = [UIColor whiteColor]; self .navigationController.navigationBar.translucent = YES ; self .navigationController.navigationBar.barTintColor = [UIColor clearColor]; self .navigationController.navigationBar.shadowImage = [UIImage new ]; [ self .navigationController.navigationBar setBackgroundImage:[UIImage new ] forBarMetrics:UIBarMetricsDefault]; if ( @available (iOS 13.0, *)) { UINavigationBarAppearance *appearance = [UINavigationBarAppearance new ]; [appearance configureWithOpaqueBackground]; // 改变导航栏的颜色 appearance.backgroundColor = [UIColor clearColor]; // 改变导航栏的标题颜色,这里改没什么用的,要去继承的父类那里去改就是 YHNavigationController.m那里 appearance.titleTextAttributes = @{ NSFontAttributeName :[UIFont systemFontOfSize:18], NSForegroundColorAttributeName :[UIColor whiteColor]}; //导航栏包含状态栏 阴影线颜色背景色设置 appearance.shadowColor = [UIColor clearColor]; self .navigationController.navigationBar.standardAppearance = appearance; self .navigationController.navigationBar.scrollEdgeAppearance = self .navigationController.navigationBar.standardAppearance; } // self.navigationItem.rightBarButtonItem.tintColor = [UIColor blackColor];//右边的按钮颜色 self .navigationItem.leftBarButtonItem.tintColor = [UIColor blackColor]; self .navigationItem.backBarButtonItem.tintColor = [UIColor blackColor]; } //返回时恢复到前面的导航栏 - ( void )viewWillDisappear:( BOOL )animated { [ super viewWillDisappear:animated]; // 导航栏恢复不透明显示 UIColor *topColor = [EBSkinLib shareInstance].globalColor_3; UIColor *bottomColor = [EBSkinLib shareInstance].globalColor; UIImage *bgImg = [UIImage gradientColorImageFromColors:@[topColor, bottomColor] gradientType:GradientTypeTopToBottom imgSize:CGSizeMake( self .view.frame.size.width, navBarHeight)]; self .navigationController.navigationBar.translucent = NO ; [ self .navigationController.navigationBar setBackgroundImage:bgImg forBarMetrics:UIBarMetricsDefault]; // self.navigationController.navigationBar.barTintColor = barTineColor; } |
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步