Skip to content

UITabBar ​

UITabBar represents the row of tabs at the bottom of the screen in a tab bar controller. Which tabs it contains is decided by the tab bar controller's viewControllers and each view controller's tabBarItem. This class is only for changing the colors of the tabs.

It is a view, but don't add subviews to it or change its frame.

Inheritance: EventTarget → NSObject → UIResponder → UIView → UITabBar

Constructor ​

It can't be created with new. new UITabBar() throws TypeError: Illegal constructor: UITabBar is created by the runtime, not by new. Read it from the tab bar controller's tabBar.

Instance properties ​

Also inherits the properties of UIView.

PropertyDescription
tintColorColor of the selected tab
unselectedItemTintColorColor of the unselected tabs

Examples ​

js
const tabs = new UITabBarController();
tabs.tabBar.tintColor = 'systemPink';
tabs.tabBar.unselectedItemTintColor = 'systemGray';

Effect: The selected tab (icon and text) is pink, and the others are gray. How the colors actually look is not verified in the simulator; reading and writing both properties has been checked.

Corresponding iOS API ​

ObjCJS
tabs.tabBar.tintColor = UIColor.systemPinkColortabs.tabBar.tintColor = 'systemPink'
tabs.tabBar.unselectedItemTintColor = UIColor.systemGrayColortabs.tabBar.unselectedItemTintColor = 'systemGray'

See also ​