In Xcode 5 Dev Preview 2, I was able to execute the following:
[[UITabBar appearance] setTintColor:[UIColor whiteColor]];
//the color of the selected image and text (white)
In Xcode 5 Dev Preview 3, the same line of code throws an exception (see below). The exception indicates that I may want to use 'barTintColor
' - but I do not - as this is the color of the overall UITabBar. How can I set the color of the selected image and text in a UITabBar?
The new exception in Xcode 5 Dev Preview 3:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-setTintColor: is not allowed for use with the appearance proxy. Perhaps you want to use the barTintColor property.'
Thank you
To change tab bar background color in Flutter, first, create a getter to return the TabBar widget and then wrap the TabBar widget inside the PreferredSize -> Material widget. Inside the Material add the color property and set the color of your choice.
backgroundColor = UIColor(red:1, green:0, blue:0, alpha:1) / UITabBar. appearance(). tintColor = UIColor(red: 1, green: 0, blue: 0, alpha: 1) // New!! func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {...}
I'm not seeing this with the latest Xcode 5 (5.0.2), but I do know that you want to call different methods to set the selected image tint color depending on whether you're running on iOS 6 or 7. Here's some sample code from one of my apps:
if ([RFSUtilities isIOS7OrHigher])
{
[[UITabBar appearance] setTintColor:[UIColor whiteColor]];
}
else
{
[[UITabBar appearance] setSelectedImageTintColor:[UIColor whiteColor]];
}
The +[RFSUtilities isIOS7OrHigher]
just checks to see whether we're running on iOS 7 or above with the proper version check:
+ (BOOL)isIOS7OrHigher
{
float versionNumber = floor(NSFoundationVersionNumber);
return versionNumber > NSFoundationVersionNumber_iOS_6_1;
}
Hope this helps!
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