UITabBar
来源:互联网 发布:天猫软件 编辑:程序博客网 时间:2024/04/30 20:52
UITabBar
需要创建多个ViewController
import “AppDelegate.h”
import “FirstViewController.h”
import “TwoViewController.h”
import “ThreeViewController.h”
import “FourViewController.h”
import “FiveViewController.h”
import “sixViewController.h”
@interface AppDelegate ()
@end
@implementation AppDelegate
(void)dealloc
{
[_window release];
[super dealloc];
}(BOOL)application:(UIApplication )application didFinishLaunchingWithOptions:(NSDictionary )launchOptions {
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
[_window release];// 创建第一个视图控制器对象
FirstViewController *firstVC=[[FirstViewController alloc] init];
// 创建第一个naVC
UINavigationController *firstNaVC=[[UINavigationController alloc] initWithRootViewController:firstVC];
// 创建tabbar上的按钮及其内容
firstVC.tabBarItem=[[[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemFeatured tag:1000] autorelease];
firstVC.tabBarItem.badgeValue=@”+99”;// 创建第二个
TwoViewController *twoVC=[[TwoViewController alloc] init];
UINavigationController *twoNaVC=[[UINavigationController alloc] initWithRootViewController:twoVC];
twoVC.tabBarItem=[[[UITabBarItem alloc] initWithTitle:@”网易” image:[UIImage imageNamed:@”6.png”] selectedImage:[UIImage imageNamed:@”5.png”]] autorelease];// 创建第三个
ThreeViewController *threeVC=[[ThreeViewController alloc] init];
UINavigationController *threeNaVC=[[UINavigationController alloc] initWithRootViewController:threeVC];
threeVC.tabBarItem=[[[UITabBarItem alloc] initWithTitle:@”添加” image:[UIImage imageNamed:@”1.png”] tag:1002] autorelease];// 创建第四个
FourViewController *fourVC=[[FourViewController alloc] init];
UINavigationController *fourNaVC=[[UINavigationController alloc] initWithRootViewController:fourVC];
fourVC.tabBarItem=[[[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemContacts tag:1003] autorelease];// 创建第五个
FiveViewController *fiveVC=[[FiveViewController alloc] init];
UINavigationController *fiveNaVC=[[UINavigationController alloc] initWithRootViewController:fiveVC];
fiveVC.tabBarItem=[[[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemBookmarks tag:1004] autorelease];// 创建第六个
sixViewController *sixVC=[[sixViewController alloc] init];
UINavigationController *sixNaVC=[[UINavigationController alloc] initWithRootViewController:sixVC];
sixVC.tabBarItem=[[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemDownloads tag:1005];
pragma mark 按钮创建好了,然后创建一个UITabbarController让所有的按钮显示出来
UITabBarController *tabVC=[[UITabBarController alloc] init];// tabbarController通过一个数组来管理所有要显示出来的naVCtabVC.viewControllers=@[firstNaVC,twoNaVC,threeNaVC,fourNaVC,fiveNaVC,sixNaVC];self.window.rootViewController=tabVC;// 对tabbar进行外观设置tabVC.tabBar.translucent=NO;// 背景颜色tabVC.tabBar.barTintColor=[UIColor orangeColor];// 点击之后的选中按钮的颜色tabVC.tabBar.tintColor=[UIColor redColor];// 设置代理人tabVC.delegate=self;// 点击进去在哪一个图标,从0开始的tabVC.selectedIndex=0;// 释放[tabVC release];[firstNaVC release];[twoNaVC release];[threeNaVC release];[fourNaVC release];[fiveVC release];[sixNaVC release];[firstVC release];[twoVC release];[threeVC release];[fourVC release];[fiveVC release];[sixVC release];return YES;
}
-(void)tabBarController:(UITabBarController )tabBarController didSelectViewController:(UIViewController )viewController{
// 点哪一个都带一个圈,不好看,不用
// viewController.tabBarItem.badgeValue=@”“;
viewController.tabBarItem.badgeValue=nil;
}
- UITabBar
- UITabBar
- UITabBar
- UITabbar
- UITabBar
- UITabBar
- UITabBar
- UITabBar
- UITabBar
- UITabBar
- UITabBar
- UITabBar
- 自定义UITabBar
- 隐藏UITabBar
- 定制 UItabbar
- Custom UITabBar
- UITabBar&UINavigation
- 隐藏 UITabBar
- fatal: Unable to create ‘xxxx/.git/index.lock': File exists.
- 程序员编程艺术第一~十章集锦与总结(教你如何编程)--持续更新中
- vmware workstation 11 安装RAC番外篇 -- 手动完全卸载GRID
- http异步大量图片下载,并用GridView显示九宫格图片样式
- PHP获取文件大小和目录大小
- UITabBar
- UNITY3D学习笔记15
- GNU组织的 gcc 和 g++ 的区别详解
- 递归:全排列的java实现
- 面试题5
- 带余除法专题
- 图的深搜与广搜
- Linux运行二进制文件时出现 can't execute :Permission denied
- 将svn插件和maven插件和findbugs插件插入到myeclipse10