| ### Creating a tab bar | |
| <!--<div class="material-code-render" markdown="1">--> | |
| #### Swift | |
| ```swift | |
| let tabBar = MDCTabBar(frame: view.bounds) | |
| tabBar.items = [ | |
| UITabBarItem(title: "Recents", image: UIImage(named: "phone"), tag: 0), | |
| UITabBarItem(title: "Favorites", image: UIImage(named: "heart"), tag: 0), | |
| ] | |
| tabBar.itemAppearance = .titledImages | |
| tabBar.autoresizingMask = [.flexibleWidth, .flexibleBottomMargin] | |
| tabBar.sizeToFit() | |
| view.addSubview(tabBar) | |
| ``` | |
| #### Objective-C | |
| ```objc | |
| MDCTabBar *tabBar = [[MDCTabBar alloc] initWithFrame:self.view.bounds]; | |
| tabBar.items = @[ | |
| [[UITabBarItem alloc] initWithTitle:@"Recents" image:[UIImage imageNamed:@"phone"] tag:0], | |
| [[UITabBarItem alloc] initWithTitle:@"Favorites" image:[UIImage imageNamed:@"heart"] tag:0], | |
| ]; | |
| tabBar.itemAppearance = MDCTabBarItemAppearanceTitledImages; | |
| tabBar.autoresizingMask = | |
| UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleBottomMargin; | |
| [tabBar sizeToFit]; | |
| [self.view addSubview:tabBar]; | |
| ``` | |
| <!--</div>--> |