Monday, June 10, 2013

UITabBarItem UITabBarSystemItemFeatured example in Objective C (iOS).


UITabBarItem UITabBarSystemItemFeatured

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.
UITabBarSystemItemFavorites
The favorites system item.
UITabBarSystemItemFeatured
The featured system item.
UITabBarSystemItemTopRated
The top rated system item.
UITabBarSystemItemRecents
The recents system item.
UITabBarSystemItemContacts
The contacts system item.
UITabBarSystemItemHistory
The history system item.
UITabBarSystemItemBookmarks
The bookmarks system item.
UITabBarSystemItemSearch
The search system item.
UITabBarSystemItemDownloads
The downloads system item.
UITabBarSystemItemMostRecent
The most recent system item.
UITabBarSystemItemMostViewed
The most viewed system item.

Discussion of [UITabBarItem UITabBarSystemItemFeatured]
The title and image of system tab bar items cannot be changed.

UITabBarItem UITabBarSystemItemFeatured example.
UITabBarItem *favorites = [[UITabBarItem alloc] initWithTitle:nil image:a1 tag:0];
UITabBarItem *topRated = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemTopRated tag:1];
UITabBarItem *featured = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemFeatured tag:2];
UITabBarItem *recents = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemRecents tag:3];

Example of [UITabBarItem UITabBarSystemItemFeatured].
UITabBarController *tabBarController = [[UITabBarController alloc] init];
[tabBarController setViewControllers:[NSArray arraywithObjects: firstViewController, secondViewController, nil]
                            animated:NO];
And to set the tab bar items:

firstViewController.tabBarItem = [UITabBarItem initWithTabBarSystemItem:UITabBarSystemItemFavorites tag:0];
secondViewController.tabBarItem = [UITabBarItem initWithTabBarSystemItem:UITabBarSystemItemFeatured tag:1];

UITabBarItem UITabBarSystemItemFeatured example.
- (void)setNewItems {
    UITabBarItem *featured = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemFeatured tag:0]; featured.badgeValue = @"1";
    UITabBarItem *mostViewed = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemMostViewed tag:1];
    UITabBarItem *search = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemSearch tag:2];
    UITabBarItem *favorites = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemFavorites tag:3];
    UITabBarItem *more = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemMore tag:4];

    [self.tabBar setItems:[NSArray arrayWithObjects:featured,
                           mostViewed,
                           search,
                           favorites,
                           more, nil] animated:NO];

}

End of UITabBarItem UITabBarSystemItemFeatured example article.