.h文件
#import <UIKit/UIKit.h>
@interface DLViewController : UITabBarController
@end
.m文件
#import "DLViewController.h"
#import "FirstViewController.h"
#import "SecondViewController.h"
#import "ThirdViewController.h"
#import "FourthViewController.h"
@interface DLViewController ()
@end
@implementation DLViewController
- (void)viewDidLoad
{
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
FirstViewController *theFirst = [[FirstViewController alloc] init];
theFirst.title = @"首页";
theFirst.tabBarItem.image = [UIImage imageNamed:@"1"];
SecondViewController *theSec = [[SecondViewController alloc] init];
theSec.title = @"视频";
theSec.tabBarItem.image = [UIImage imageNamed:@"5"];
ThirdViewController *theThird = [[ThirdViewController alloc] init];
theThird.title = @"关注";
theThird.tabBarItem.image = [UIImage imageNamed:@"3"];
// 红点
theThird.tabBarItem.badgeValue = @"100";
FourthViewController *theFourth = [[FourthViewController alloc] init];
theFourth.title = @"我的";
theFourth.tabBarItem.image = [UIImage imageNamed:@"6"];
UINavigationController *theNav1 = [[UINavigationController alloc] initWithRootViewController:theFirst];
UINavigationController *theNav2 = [[UINavigationController alloc] initWithRootViewController:theSec];
UINavigationController *theNav3 = [[UINavigationController alloc] initWithRootViewController:theThird];
UINavigationController *theNav4 = [[UINavigationController alloc] initWithRootViewController:theFourth];
self.viewControllers = @[theNav1,theNav2,theNav3,theNav4];
}
@end