UITabBarController
来源:互联网 发布:centos系统指令 编辑:程序博客网 时间:2024/05/16 12:34
//设置tabBar的颜色
tbc.tabBar.barTintColor = [UIColor whiteColor];
//设置选中时的颜色
tbc.tabBar.tintColor = [UIColor greenColor];
//设置tabBar的背景图片
tbc.tabBar.backgroundImage = [UIImage imageNamed:@”tabbar_bg”];
//定制tabbaritem
UITabBarItem *tbi = [[UITabBarItem alloc] initWithTitle:@”微信” image:image selectedImage:selectedImage];
//设置字体及颜色
[tbi setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:15], NSForegroundColorAttributeName:normalColor} forState:UIControlStateNormal];
[tbi setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:15],NSForegroundColorAttributeName:selectedColor} forState:UIControlStateSelected];
//自定制tabbar需隐藏系统tabbar
//首先隐藏系统tabBar
self.tabBar.hidden = YES;//self为tabbarcontroller
“`
//设置代理
tbc.delegate = self;
//读取以保存在沙盘里的选中下标
tbc.selectedIndex = [[NSUserDefaults standardUserDefaults] integerForKey:@”selectedIndex”];
//说明:下面代理方法是UITabBarControllerDelegate选中tabbaritem时代理方法,可以把选中时的下表保存到本地沙盘里
pragma mark - 代理方法
(void)tabBarController:(UITabBarController )tabBarController didSelectViewController:(UIViewController )viewController
{
//获取选中下标
NSUInteger selectedIndex = tabBarController.selectedIndex;
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
//会保存到沙盒目录,一般只保存小数据(状态记录等)
[ud setInteger:selectedIndex forKey:@”selectedIndex”];
//上面写不会立即写进入,下面的语句可以立即写入
[ud synchronize];//打印沙盒目录
//NSLog(@”%@”, NSHomeDirectory());
}
“`
- UITabbarController
- UITabBarController
- UITabBarController
- UITabBarController
- UITabBarController
- UITabBarController
- UITabbarController
- UITabBarController
- UITabBarController
- UITabBarController
- UITabbarController
- UITabBarController
- UITabBarController
- UITabBarController
- UITabBarController
- UITabBarController
- UITabBarController
- UITabBarController
- 判断请求时手机端访问还是电脑端访问
- javaWeb中解决中文乱码问题
- hdu1024Max Sum Plus Plus【状态dp 滚动数组】
- 使用Linux的sar 命令来计算Linux的内存剩余
- 黑马程序员——Java基础(六)之常用类
- UITabBarController
- android Jsoup获取网站内容(实例为新闻标题获取),android网络必学
- lambda表达式,结合map、reduce、filter函数
- iOS几种界面跳转方式简介
- Hadoop YARN架构设计要点
- c++原型模式
- Browser 相关内容
- hdu 5495 LCS (bestcoder #58 1002)
- Edison install ROS in two method