UINavigationController和UITabBarController合用。

简介: UINavigationController和UITabBarController合用。
TabPage1 *firstViewControlle = [[TabPage1 alloc] init];
    UINavigationController *nav1 = [[UINavigationController alloc] initWithRootViewController: firstViewControlle];
    UITabBarItem *time = [[UITabBarItem alloc] initWithTitle: @"First" image: nil tag: 0];
    time.image = [UIImage imageNamed:@""];
    nav1.tabBarItem = time;
    TabPage2 *secondViewController = [[TabPage2 alloc] init];
    UINavigationController *nav2 = [[UINavigationController alloc] initWithRootViewController: secondViewController];
    UITabBarItem *time2 = [[UITabBarItem alloc] initWithTitle: @"second" image: nil tag: 1];
    nav2.tabBarItem = time2;
    UITabBarController *tabBarController = [[UITabBarController alloc] init];
    NSArray *array = [NSArray arrayWithObjects: nav1,nav2, nil];
    tabBarController.viewControllers = array;
    [self presentViewController:tabBarController animated:YES completion:nil];
///在TabPage1中
self.navigationitem.title = @"111";
 //设置Navigation Bar背景图片
   UIImage *title_bg = [UIImageimageNamed:@"头.png"]; //获取图片
    CGSize titleSize =self.navigationController.navigationBar.bounds.size; //获取Navigation Bar的位置和大小
    //title_bg.size = [self scaleToSize:title_bg size:titleSize];//设置图片的大小与Navigation Bar相同
 [nav1.navigationBarsetBackgroundImage:title_bg forBarMetrics:UIBarMetricsDefault]; //设置背景
 [nav1.navigationBarsetBarStyle:UIBarStyleBlack];

设置Title颜色

   NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    [dic setObject:[UIColor whiteColor] forKey:UITextAttributeTextColor];
    [dic setObject:[UIFont systemFontOfSize:19] forKey:UITextAttributeFont];
    self.navigationController.navigationBar.titleTextAttributes = dic;
相关文章
|
5月前
|
iOS开发 UED 容器
navigationController 的使用详解
navigationController 的使用详解
|
6月前
|
iOS开发 容器
什么是 UINavigationController 和 UITabBarController?它们有什么作用?
什么是 UINavigationController 和 UITabBarController?它们有什么作用?
43 2
UITabBarController 获得selecdIndex
UITabBarController 获得selecdIndex
76 0
|
容器
(三)UITabBarController和UITabBar的基本用法
(三)UITabBarController和UITabBar的基本用法
319 0