Same question as this, but that question was shunned (because of NDA at the time) and is no longer active.
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** Illegal property type, c for appearance setter, _installAppearanceSwizzlesForSetter:'
I'm setting this in viewDidLoad
of my initial view controller. setTranslucent
comes up on autocomplete, and does not complain until crashing and talking about swizzles and things.
Any info on this would be great, I'm still having a very rough time getting a consistent status bar appearance across my app.
isTranslucent: A Boolean value indicating whether the navigation bar is translucent (true) or not (false). isOpaque: A Boolean value indicating whether the title is empty and an opaque bezel is set.
The appearance settings for the navigation bar when the edge of scrollable content aligns with the edge of the navigation bar. iOS 13.0+ iPadOS 13.0+ Mac Catalyst 13.1+ tvOS 13.0+
You need to do three things to make a navigation bar transparent. Set background image to non-nil empty image ( UIImage() ). Set shadow image to non-nil empty image ( UIImage() ).
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
}
You can fool it though by specifying a non exist image, which will amke the 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];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With