Sunday, June 9, 2013

UINavigationBar translucent example in Objective C (iOS).


UINavigationBar translucent

A Boolean value indicating whether the navigation bar is only partially opaque.

@property(nonatomic, assign, getter=isTranslucent) BOOL translucent

Discussion of [UINavigationBar translucent]
Always set to YES if the barStyle property contains the value UIBarStyleBlackTranslucent. When YES, the navigation bar is drawn with partial opacity, regardless of the bar style. The amount of opacity is fixed and cannot be changed.

It is permissible to set the value of this property when the navigation bar is being managed by a navigation controller object.

UINavigationBar translucent example.
the translucent property of UINavigationBar. Try:

[[self.navigationController navigationBar] setTranslucent:YES];

Example of [UINavigationBar translucent].
Once you know it, it's fairly simple:

self.navigationController.navigationBar.tintColor = [UIColor blueColor];
self.navigationController.navigationBar.alpha = 0.7f;
self.navigationController.navigationBar.translucent = YES;
The translucent property seems only to determine wether the main view should be visible under the navigation bar, and resizes the view appropiately.

UINavigationBar translucent example.
At least in iOS 6 on an iPhone 4S, you can make a colored translucent navigation bar like this:

self.navigationController.navigationBar.tintColor = [UIColor blueColor];
self.navigationController.navigationBar.translucent = YES;
The alpha setting doesn't seem to be necessary anymore. This also leaves my title bright white and my buttons opaque.

End of UINavigationBar translucent example article.