zoukankan      html  css  js  c++  java
  • UITabBar分栏控制器

     /*  分栏控制器基础流程
         *  第一步:把需要展示的页面创建出来。
         *  第二步:如果需要,就把页面封装到导航里
         *  第三步:设置每个页面/导航对应的专用按钮(tabBar上的)
         *  第四步:把这些页面/导航放到数组里,并和tabBarController关联
         */

     1 /*******分栏控制器的专用按钮,是让每个页面单独设置的********/
     2     
     3     UITabBarItem *atbi = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemFavorites tag:0    ];
     4     //使用系统自带的风格创建分栏专用按钮
     5     anc.tabBarItem = atbi;
     6     [atbi release];
     7     
     8     UITabBarItem *btib = [[UITabBarItem alloc] initWithTitle:@"bb" image:[UIImage imageNamed:@"tab0_2"] tag:0];
     9     //使用标题和图片创建(标准大小是30*30(60*60))
    10     bv.tabBarItem = btib;
    11     [btib release];
    12     
    13     UITabBarItem *ctbi = [[UITabBarItem alloc] initWithTitle:@"ctbi" image:[UIImage imageNamed:@"tab1_1"] selectedImage:[UIImage imageNamed:@"tab1_2"]];
    14     //使用标题和2张图片创建
    15     cv.tabBarItem = ctbi;
    16     [ctbi release];
    17     
    18     self.viewControllers = [NSArray arrayWithObjects:anc, bv, cv, dv, nil];
    19     
    20     [anc release];
    21     [bv release];
    22     [cv release];
    23     [dv release];
    24     
    25     self.tabBar.tintColor = [UIColor greenColor];
    26     //内容的渲染色
    27     
    28     self.tabBar.barTintColor = [UIColor blackColor];
    29     //背景色
    30     
    31     self.tabBar.backgroundImage = [UIImage imageNamed:@"tabbg"];
    32     //背景图片
    33     
    34     //设置anc的title上的文字字体和颜色
    35     NSDictionary *titleDic = [NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:14], NSFontAttributeName, [UIColor redColor], NSForegroundColorAttributeName, nil];
    36     
    37     anc.navigationBar.titleTextAttributes = titleDic;
    38     //设置导航条上title的文字属性(针对整个导航有效)
    39     
    40     [atbi setTitleTextAttributes:titleDic forState:UIControlStateNormal];
    41     //设置tabBar上专用按钮的文字属性(一般不设颜色)

      dv.hidesBottomBarWhenPushed = YES;
        //当新页面被push的时候,自动隐藏底部tabBar,返回时也会自动出现

  • 相关阅读:
    MyBatis---集合查询(一对多)
    MyBatis---简单关系查询
    MyBatis---简介
    MyBatis---简单增删改查的带事物的例子
    log4j.properties配置文件详解
    Hibernate---实体类注释简介
    Hibernate---数据操作示例BY实体类注释
    Hibernate---数据操作示例BY实体映射文件
    JDBC---java与数据库中数据类型的对应关系
    Hibernate---session
  • 原文地址:https://www.cnblogs.com/Angelone/p/4387005.html
Copyright © 2011-2022 走看看