TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

iOS | Tab Bar Item

iOS | Tab Bar Item with XCode IDE Introduction, History and Versions, Views and View Controllers, Creating the first iOS application, Label, Button, TextField, Switch, Segmented Control, iOS UI Controls, iOS UI Views, iOS UIView Controllers, Tab Bar Interface etc.

<< Back to IOS

Tab Bar Item

The Tab bar item is the one that represents the view controller when it is added to a tab bar controller. It is an item of the tab bar by tapping on which, a new view appears above the tab bar. A Tab bar item is the instance of the UITabBarItem class, which inherits UIBarItem class.

class UITabBarItem : UIBarItem

A TabBarItem is used in the tab bar interface. A Tab bar operates in the radio mode where the user can-not selects two-tab bar items simultaneously. We can configure the appearance of a tab bar item using the properties of the UITabBarItem class. We can also specify the badge value for an item that is being used in almost every iOS application. The badge value is used to show some important information about the current state of View Controller. For example, in the Facebook application, the message tab is shown with a badge representing the number of new messages received.

Configuring TabBarItem appearance

We can configure the appearance of a TabBarItem using the attribute inspector in the storyboard. We can configure the following attributes of a TabBarItem using storyboard.

iOS Tab Bar Item

Here, we will configure the appearance of a tab bar item that we created in the TabBarController Example 1.

Let's add a badge value for the item, as shown in the following image.

iOS Tab Bar Item

If we run this application, we will get the following output.

iOS Tab Bar Item

We can use the init(tabBarSystemItem:tag:) method to create one of the system items. Also, we can use the init(title:image:tag:) method to create a custom item with the specified title and image, which is used as both the unselected and selected image. We use the init(title:image:selectedImage:) method to create a custom item with the specified title, unselected image, and selected image.

The More Navigation Controller

The TabBar associated with the tab bar controller has a limited space to show the custom tab bar items. However, if we add more than four items to a tab bar, then the tab bar contains only the first four items along with the more option to display the additional items. The more item presents a standard interface to select the additional items. Let's look at the following example.

Example

Let's add three more view controllers to the Example shown above and define the View Controllers relationship with the tab bar controller. The interface builder will look like the following image.

iOS Tab Bar Item

Let's run the project. It will generate the following output.

iOS Tab Bar Item




Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf