首页 技术 正文
技术 2022年11月18日
0 收藏 711 点赞 3,251 浏览 2454 个字

前言

通常做一个项目前,不算开始讨论需求,分析产品等等,一开始会给我们搭建一个框架,今天简单说一下搭建框架.

github网址:https://github.com/Moonths/iWatch.git

效果图

做一个项目前搭建一个tabBar(一)框架做一个项目前搭建一个tabBar(一)框架

正文

1.创建几个ViewController添加到TabBarController上,一般添加3-4个tabBar,最多不过5个,5个以上之后用户体验就不好了.

2.创建好之后依次引入头文件,在viewDidLoad上添加

      //TalkViewController.h
TalkViewController *talkVC = [[TalkViewController alloc] init];
UINavigationController *talkNC = [[UINavigationController alloc] initWithRootViewController:talkVC];
talkNC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"消息" image:[UIImage imageNamed:@"iconfont-12.png"] selectedImage:[UIImage imageNamed:@"iconfont-12-1.png"] ]; //MessageViewController.h
MessageViewController *messageVC = [[MessageViewController alloc] init];
UINavigationController *messageNC = [[UINavigationController alloc] initWithRootViewController:messageVC];
messageNC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"活动" image:[UIImage imageNamed:@"iconfont-4.png"] selectedImage:[UIImage imageNamed:@"iconfont-4-1.png"] ]; //MeViewController.h
MeViewController *meVC = [[MeViewController alloc] init];
UINavigationController *meNC = [[UINavigationController alloc] initWithRootViewController:meVC];
meNC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"我" image:[UIImage imageNamed:@"iconfont-wo.png"] selectedImage:[UIImage imageNamed:@"iconfont-wo-1.png"]]]; self.viewControllers = @[talkNC,messageNC,meNC];

3.改变属性

上面的代码点击tabBar的时候并不是你放上的图片颜色,要加一个属性

  talkNC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"消息" image:[UIImage imageNamed:@"iconfont-12.png"] selectedImage:[[UIImage imageNamed:@"iconfont-12-1.png"]  imageWithRenderingMode: UIImageRenderingModeAlwaysOriginal]];
messageNC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"活动" image:[[UIImage imageNamed:@"iconfont-4.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[[UIImage imageNamed:@"iconfont-4-1.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
meNC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"我" image:[[UIImage imageNamed:@"iconfont-wo.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[[UIImage imageNamed:@"iconfont-wo-1.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];

4.改变下面tabBar的背景颜色

  //改变tabBar的背景颜色
UIView *backView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 49)];
backView.backgroundColor = [UIColor grayColor];
[self.tabBar insertSubview:backView atIndex:0];
//opaque默认是YES 不透明的意思
self.tabBar.opaque = YES;

5.改变tabBar上的字体颜色

    //设置字体的颜色
self.tabBar.tintColor = [UIColor whiteColor];

miaomiaoccat小语

这个代码比较简单,我就没有传到github上,上面基本是全部代码,应该可以完成,有不对的地方欢迎指教.请留言.

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,497
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,910
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,744
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,498
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:8,135
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:5,299