The behavior of tintColor
for bars has changed in iOS 7.0. It no longer affects the bar's background.
From the documentation:
barTintColor Class Reference
The tint color to apply to the navigation bar background.
@property(nonatomic, retain) UIColor *barTintColor
Discussion
This color is made translucent by default unless you set the translucent property to NO
.
Availability
Available in iOS 7.0 and later.
Declared In
UINavigationBar.h
Code
NSArray *ver = [[UIDevice currentDevice].systemVersion componentsSeparatedByString:@"."];
if ([[ver objectAtIndex:0] intValue] >= 7) {
// iOS 7.0 or later
self.navigationController.navigationBar.barTintColor = [UIColor redColor];
self.navigationController.navigationBar.translucent = NO;
}else {
// iOS 6.1 or earlier
self.navigationController.navigationBar.tintColor = [UIColor redColor];
}
We can also use this to check iOS Version as mention in iOS 7 UI Transition Guide
if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1) {
// iOS 6.1 or earlier
self.navigationController.navigationBar.tintColor = [UIColor redColor];
} else {
// iOS 7.0 or later
self.navigationController.navigationBar.barTintColor = [UIColor redColor];
self.navigationController.navigationBar.translucent = NO;
}
EDIT
Using xib
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…