给app同时加上Tab Bar和Navigation Controller的方法

用storyboard的操作给程序加上Tab Bar 和 Navigation Controller的方法都是很容易找到的,但是同时用storyboard完成这两者的较少,故总结一下。
完成过程中参考了http://blog.csdn.net/nextstudio/article/details/42120017
首先,用storyboard创建一个Tab Bar控制的三个(不一定三个)ViewController(先对原有的ViewController用Editor->Embed in->Tab Bar Controller,然后添加拉取一个ViewController并创建对应的ViewController类,并在storyboard中右键Tab Bar Controller连线到第二个页面,同样可以创建更多的页面),总而言之就是单独创建Tab Bar控制的页面的方法,可以查到。

然后在Storyboard中选中一个ViewController,用Editor->Embed in->Navigation Controller方法创建导航栏,然后就会发现Storyboard中这个页面的前面多了一个Navigation Controller,同理可以给其他页面创建导航栏。
效果如图
用stroyboard同时添加TabBarController和NavigationController并给TabBarItem添加图片

给Tab Bar Item添加图片

Tab Bar Item如果没有图片是单调的,选中如图的Bar Item用stroyboard同时添加TabBarController和NavigationController并给TabBarItem添加图片
然后在attributes inspector中设置Tab Bar Item按钮的标题和图片,可以在attributes inspector中选择预设的一些系统按钮选项,也可以自己定义,如图。用stroyboard同时添加TabBarController和NavigationController并给TabBarItem添加图片
要注意的是图片的大小,可以去看卡Apple的人机交互开发指南https://developer.apple.com/ios/human-interface-guidelines/icons-and-images/custom-icons/
里面写了普通的TabBarItem图片可以设成75*75像素的大小,注意文件名要有@3x.png结尾(如果是png),如果是50*50的大小,就要以@2x.png结尾。
先把图片大小和文件名设置好,然后拖进工程,然后就可以直接在attributes inspector中指定图片了。

相关文章:

  • 2022-12-23
  • 2021-09-22
  • 2022-12-23
  • 2022-12-23
  • 2021-12-30
  • 2021-07-20
  • 2021-05-16
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-30
  • 2021-12-27
相关资源
相似解决方案