UITabBarController
来源:互联网 发布:人大经济论坛数据 编辑:程序博客网 时间:2024/04/29 20:29
1、新建ios工程,并添加几个自定义UIViewController,分别取名为MyViewController1,MyViewController2,MyViewController3,
2、AppDelegate中如下初始化
#import "AppDelegate.h"#import "MyViewController1.h"#import "MyViewController2.h"#import "MyViewController3.h"//#import "MyViewController4.h"@interface AppDelegate ()@end@implementation AppDelegate- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. self.window=[[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds]; UITabBarController* tb=[[UITabBarController alloc]init]; UIViewController* vc1=[[MyViewController1 alloc]init]; vc1.tabBarItem.title=@"首页"; //避免图片不显示 vc1.tabBarItem.image=[[UIImage imageNamed:@"img1.png"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; UIViewController* vc2=[[MyViewController2 alloc]init]; vc2.tabBarItem.title=@"消息"; UIViewController* vc3=[[MyViewController3 alloc]init]; vc3.tabBarItem.title=@"设置"; tb.viewControllers=@[vc1,vc2,vc3]; //设置底部tab背景 tb.tabBar.backgroundImage=[UIImage imageNamed:@"tb.png"]; self.window.rootViewController=tb; [self.window makeKeyAndVisible]; return YES;}
3、自定义各个自定义UIViewController界面,例如
#import "MyViewController2.h"@interface MyViewController2 ()@end@implementation MyViewController2- (void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor=[UIColor greenColor]; self.tabBarItem.title=@"Vc2title"; //设置图片 self.tabBarItem.image=[[UIImage imageNamed:@"img1.png"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; self.tabBarItem.badgeValue=@"5";//显示5条未读消息 // Do any additional setup after loading the view.}
效果图如下
0 0
- UITabbarController
- UITabBarController
- UITabBarController
- UITabBarController
- UITabBarController
- UITabBarController
- UITabbarController
- UITabBarController
- UITabBarController
- UITabBarController
- UITabbarController
- UITabBarController
- UITabBarController
- UITabBarController
- UITabBarController
- UITabBarController
- UITabBarController
- UITabBarController
- android dnk 引导
- 创建一个MD5加密工具类
- 分析 ecshop 里的$GLOBALS
- 用户是否开启定位服务
- 简单的QQ在线客服
- UITabBarController
- OS X编程: 使用Core Animation
- Code Forces 582 B. Once Again...(LIS)
- 如何在Hive中实现递归计算
- mysql备份
- soapui模拟桩mockservice---模拟后台服务器
- github代码仓库
- NOIP2013提高组初赛
- 百度云文件校验方式猜想