iOS 7 : Disable UINavigationBar Translucency For Entire App

后端 未结 9 1847
Happy的楠姐
Happy的楠姐 2020-12-14 14:12

Is there a way to disable UINavigationBar Translucency for an entire application?

I\'m aware that using [self.navigationController.navigationBar setTranslucent

相关标签:
9条回答
  • 2020-12-14 14:43

    Adding this in case anyones still battling this.

    You can fool it though by specifying a non exist image, which will make the nav bar INCLUDING it's tool bar go opaque

    [[UIToolbar appearance] setBackgroundColor:[UIColor colorWithRed:219.0/255.0 green:67.0/255.0 blue:67.0/255.0 alpha:1.0]];
    
    [[UIToolbar appearance] setBackgroundImage:[[UIImage alloc] init] forToolbarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];
    
    0 讨论(0)
  • 2020-12-14 14:43

    If you don't use storyboard, but IB, set the navigation bar style of your MainWindows.xib to NOT translucent and set as color not the clear color.

    0 讨论(0)
  • 2020-12-14 14:44

    Here is a Swift solution if you want to apply this Styling to the whole app.

    in the AppDelegate class add this to the didFinishLaunchingWithOptions:

    For Swift 2:

    UINavigationBar.appearance().translucent = false
    

    For Swift 3+:

    UINavigationBar.appearance().isTranslucent = false
    
    0 讨论(0)
提交回复
热议问题