制作自定义tabBar的方法 [英] Approach to make a custom tabBar

查看:124
本文介绍了制作自定义tabBar的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

创建这样的效果以及导航控制器和视图控制器的处理的最佳方法应该是什么...如果我不想在viewcontorller中重新调整每个后续视图的大小并且看起来好像它是一个tabBar



解决方案

我建议将UIImageView用于蓝色背景,然后将5个自定义类型的UIButton与PNG图像用作实际按钮。 / p>

子类化UIView并将所有代码设置为init函数中的背景和按钮。这样,您可以轻松地将自定义TabBar放置在您想要的任何位置。



各个按钮还可以让您轻松地为过渡设置动画效果。



更新以反映更新的问题:



如果您想要实际的UITabBar功能,事情会变得更加复杂。



您有三个基本选择:



a)在新课程中从头实现所需的功能。



b)子类化UITabBar,并尝试使用上面的代码覆盖绘图代码



c)看一下在已经存在的 UITabBar的替代实现,然后将其中的新课程作为其中的一项。这可能是最简单的解决方案。


What should be the best way to create a effect like this and the handling of navigation controllers and view controllers ... what to do if I don't want to re-size each subsequent view in viewcontorller and things appear as if it is a tabBar

解决方案

I would recommend using an UIImageView for the blue background, then 5 UIButtons of custom type with PNG images for the actual buttons.

Subclass UIView and put all the code to set up the background and buttons in the init function. That way you can easily place your custom TabBar wherever you like.

The individual buttons also allow you to easily animate them for transitions if you want.

Update to reflect updated question:

If you want the actual UITabBar functionality, things become much more complex.

You have three basic options:

a) Implement the functionality you need from scratch in your new class

b) Subclass UITabBar and try to override the drawing code with the code above

c) Take a look at already existing alternative implementations of UITabBar and base your new class on one of them. This will probably be the easiest solution.

这篇关于制作自定义tabBar的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆