Why does [[UINavigationBar appearance] setTranslucent:NO] crash my app?

It seems that the translucent property just can’t be set using UIAppearance. I don’t know exactly why, but I guess some properties just aren’t supported. However, I solved this by creating a custom UIViewController and making all other viewControllers in my app a subclass of that custom viewController. That way, I can set global properties (such as translucent in your case) that will be inherited by all other viewControllers in my app. I know that’s kind of a big change, but I hope it helps.

**** EDIT ****

As of iOS 8, translucency can be set with UIAppearance:

Objective C

if([UIDevice currentDevice].systemVersion.floatValue >= 8.0) {

    [[UINavigationBar appearance] setTranslucent:YES];
}

Swift

if (UIDevice.currentDevice().systemVersion as NSString).floatValue >= 8.0 {

    UINavigationBar.appearance().translucent = true
}

Leave a Comment