iOS Reference Library Apple Developer
Search

UITabBarItem Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/UIKit.framework
Availability
Available in iOS 2.0 and later.
Declared in
UITabBarItem.h

Overview

The UITabBarItem class implements an item on a tab bar, instances of the UITabBar class. A tab bar operates strictly in radio mode, where one item is selected at a time—tapping a tab bar item toggles the view above the tab bar. You can also specify a badge value on the tab bar item for adding additional visual information—for example, the Phone application uses a badge on the item to show the number of new messages. This class also provides a number of system defaults for creating items.

Use the initWithTabBarSystemItem:tag: method to create one of the system items. Use the initWithTitle:image:tag: method to create a custom item with the specified title and image.

Tasks

Initializing a Item

Getting and Setting Properties

Properties

For more about Objective-C properties, see “Properties” in The Objective-C Programming Language.

badgeValue

Text that is displayed in the upper-right corner of the item with a surrounding red oval.

@property(nonatomic, copy) NSString *badgeValue

Discussion

The default value is nil.

Availability
  • Available in iOS 2.0 and later.
Declared In
UITabBarItem.h

Instance Methods

initWithTabBarSystemItem:tag:

Creates and returns a new item containing the specified system item.

- (id)initWithTabBarSystemItem:(UITabBarSystemItem)systemItem tag:(NSInteger)tag

Parameters
systemItem

The system item to use as the first item on the tab bar. One of the constants defined in UITabBarSystemItem.

tag

The receiver’s tag, an integer that you can use to identify bar item objects in your application.

Return Value

A newly initialized item containing the specified system item. The item’s target is nil.

Discussion

This method returns a system-supplied tab bar item. The title and image properties of the returned item cannot be changed later.

Availability
  • Available in iOS 2.0 and later.
Declared In
UITabBarItem.h

initWithTitle:image:tag:

Creates and returns a new item using the specified properties.

- (id)initWithTitle:(NSString *)title image:(UIImage *)image tag:(NSInteger)tag

Parameters
title

The item’s title. If nil, a title is not displayed.

image

The item’s image. If nil, an image is not displayed.

The images displayed on the tab bar are derived from this image. If this image is too large to fit on the tab bar, it is scaled to fit. The size of an tab bar image is typically 30 x 30 points. The alpha values in the source image are used to create the unselected and selected images—opaque values are ignored.

tag

The receiver’s tag, an integer that you can use to identify bar item objects in your application.

Return Value

Newly initialized item with the specified properties.

Availability
  • Available in iOS 2.0 and later.
Declared In
UITabBarItem.h

Constants

UITabBarSystemItem

System items that can be used on a tab bar.

typedef enum {
   UITabBarSystemItemMore,
   UITabBarSystemItemFavorites,
   UITabBarSystemItemFeatured,
   UITabBarSystemItemTopRated,
   UITabBarSystemItemRecents,
   UITabBarSystemItemContacts,
   UITabBarSystemItemHistory,
   UITabBarSystemItemBookmarks,
   UITabBarSystemItemSearch,
   UITabBarSystemItemDownloads,
   UITabBarSystemItemMostRecent,
   UITabBarSystemItemMostViewed,
} UITabBarSystemItem;
Constants
UITabBarSystemItemMore

The more system item. more item

Available in iOS 2.0 and later.

Declared in UITabBarItem.h.

UITabBarSystemItemFavorites

The favorites system item. favorites item

Available in iOS 2.0 and later.

Declared in UITabBarItem.h.

UITabBarSystemItemFeatured

The featured system item. featured item

Available in iOS 2.0 and later.

Declared in UITabBarItem.h.

UITabBarSystemItemTopRated

The top rated system item. top-rated item

Available in iOS 2.0 and later.

Declared in UITabBarItem.h.

UITabBarSystemItemRecents

The recents system item. recents item

Available in iOS 2.0 and later.

Declared in UITabBarItem.h.

UITabBarSystemItemContacts

The contacts system item. contacts item

Available in iOS 2.0 and later.

Declared in UITabBarItem.h.

UITabBarSystemItemHistory

The history system item. history item

Available in iOS 2.0 and later.

Declared in UITabBarItem.h.

UITabBarSystemItemBookmarks

The bookmarks system item. bookmarks item

Available in iOS 2.0 and later.

Declared in UITabBarItem.h.

UITabBarSystemItemSearch

The search system item. search item

Available in iOS 2.0 and later.

Declared in UITabBarItem.h.

UITabBarSystemItemDownloads

The downloads system item. downloads item

Available in iOS 2.0 and later.

Declared in UITabBarItem.h.

UITabBarSystemItemMostRecent

The most recent system item. most recent item

Available in iOS 2.0 and later.

Declared in UITabBarItem.h.

UITabBarSystemItemMostViewed

The most viewed system item. most viewed item

Available in iOS 2.0 and later.

Declared in UITabBarItem.h.

Discussion

The title and image of system tab bar items cannot be changed.

Availability
  • Available in iOS 2.0 and later.
Declared In
UITabBarItem.h



Last updated: 2009-03-05

Did this document help you? Yes It's good, but... Not helpful...