I ported a file from Objective_c to Swift that among its configurations changed the tabbar color: the code I used in objective-c was:
UIColor* barColor=[UIColor colorWithRed:.88 green:.05 blue:.05 alpha:1];
if([self.navigationController.navigationBar respondsToSelector:@selector(barTintColor)])
{
/
self.navigationController.navigationBar.barTintColor = barColor;
}
else
{
[[UINavigationBar appearance] setTintColor:barColor];
/
/
}
[super viewWillAppear:animated];
and the corresponding Swift code is:
let barColor = UIColor(red:0.88, green:0.05, blue:0.05, alpha:1)
if UIDevice.currentDevice().systemVersion.compare("8.0", options: .NumericSearch) == .OrderedDescending
{
/
UINavigationBar.appearance().tintColor=barColor
/
}
else
{
self.navigationController!.navigationBar.barTintColor = barColor;
}
Yet, while the objective-c code did change the tab-bar color, the corresponding swift code leaves it unscathed, at least on the simulator.
What is even more puzzling is that I have a sister ViewController in which I use:
self.navigationController!.navigationBar.barTintColor = barColor
even on iOS 9 without any crash altogether and its execution actually changes the color of the tabbar.
If I use that piece of code in the original viewcontroller on iOS 9 I have a crash instead, and the alternative code has no effect.