xcode iOS UINavigationBar vs UIToolbar vs UITabBar
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1722795/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
iOS UINavigationBar vs UIToolbar vs UITabBar
提问by Brij
Let me know which one should be used in what case.
让我知道在什么情况下应该使用哪个。
What are differences among them?
它们之间有什么区别?
What are the advantage and disadvantage of each component?
每个组件的优缺点是什么?
回答by Mez
The UINavigationBarclass implements a control for navigating hierarchical content. It's a bar, typically displayed at the top of the screen, containing buttons for navigating up and down a hierarchy. The primary properties are a left (back) button, a center title, and an optional right button.
该UINavigationBar的类实现导航层次内容的控制。它是一个栏,通常显示在屏幕顶部,包含用于在层次结构中上下导航的按钮。主要属性是左(后退)按钮、中心标题和可选的右按钮。
An instance of the UIToolbarclass is a control for selecting one of many buttons, called toolbar items. A toolbar momentarily highlights or does not change the appearance of an item when tapped. Use the UITabBar class if you need a radio button style control.
UIToolbar类的一个实例是用于选择许多按钮之一的控件,称为工具栏项。点击时,工具栏会暂时突出显示或不更改项目的外观。如果您需要单选按钮样式控件,请使用 UITabBar 类。
The UITabBarclass implements a control for selecting one of two or more buttons, called items. The most common use of a tab bar is to implement a modal interface where tapping an item changes the selection.
所述UITabBar类用于实现选择的两个或多个按钮,称为项目之一的控制。标签栏最常见的用途是实现一个模式界面,点击一个项目会改变选择。
回答by Chris S
To quote big brother:
引用大哥的话:
Tabbar
If your application provides different perspectives on the same set of data, or different subtasks related to the overall function of the application, you might want to use a tab bar. A tab bar appears at the bottom edge of the screen.
A tab bar gives users the ability to switch among different modes or views in an application, and users should be able to access these modes from everywhere in the application
标签栏
如果您的应用程序对同一组数据提供不同的视角,或者与应用程序的整体功能相关的不同子任务,您可能需要使用标签栏。一个标签栏出现在屏幕的底部边缘。
标签栏使用户能够在应用程序中的不同模式或视图之间切换,并且用户应该能够从应用程序的任何地方访问这些模式
Toolbar
If your application provides a number of actions users can take in the current context, it might be appropriate to provide a toolbar
工具栏
如果您的应用程序提供了许多用户可以在当前上下文中执行的操作,则提供一个工具栏可能是合适的
However that doesn't give you a completely clear application-based decision. The best solution is to look at the iPhone inbuilt applications (Clock and iPod) along with Appstore-approved apps and stick to what is consistent, as that is what the Apple HIG guides and the appstore approval process boils down to.
然而,这并没有给你一个完全明确的基于应用程序的决定。最好的解决方案是查看 iPhone 内置应用程序(Clock 和 iPod)以及 Appstore 批准的应用程序,并坚持一致的内容,因为这是 Apple HIG 指南和 Appstore 批准过程归结为的内容。
回答by Ben Gottlieb
You should take a look at the Mobile HIG(Human Interface Guidelines) for these questions.
对于这些问题,您应该查看移动 HIG(人机界面指南)。
回答by leanne
As of June 2018, the Human Interface Guidelines (HIG)include the most current expectations for iOS, macOS, watchOS, and tvOS, including links to details for developers.
截至 2018 年 6 月,人机界面指南 (HIG)包括对 iOS、macOS、watchOS 和 tvOS 的最新期望,包括指向开发人员详细信息的链接。
For iOS, the guideline summaries are:
对于 iOS,指南摘要是:
导航栏:
A navigation bar appears at the top of an app screen, below the status bar, and enables navigation through a series of hierarchical screens.
导航栏出现在应用程序屏幕的顶部,状态栏的下方,可以通过一系列分层屏幕进行导航。
工具栏:
A toolbar appears at the bottom of an app screen and contains buttons for performing actions relevant to the current view or content within it.
工具栏出现在应用程序屏幕的底部,包含用于执行与当前视图或其中内容相关的操作的按钮。
标签栏:
A tab bar appears at the bottom of an app screen and provides the ability to quickly switch between different sections of an app.
标签栏出现在应用程序屏幕的底部,提供了在应用程序的不同部分之间快速切换的能力。
As far as advantages and disadvantages of each, one important aspect is whether you want the bar to appear at the top or bottom of a view. Navigation bars are supposed to appear at the top, while toolbars and tab bars are expected to appear at the bottom of the view.
就每个优点和缺点而言,一个重要方面是您希望栏出现在视图的顶部还是底部。导航栏应该出现在顶部,而工具栏和标签栏应该出现在视图的底部。
Another is whether you want navigation functionality vs actions/tasksrelated to a view. Navigation Bars implement a button to return to the previous view in the stack, tab bars provide a more abrupt change (such as switching from an alarm view to a timer view, say), and toolbars are really intended for actions (such as sharing, say) rather than actual "navigation".
另一个是您是否想要导航功能与与视图相关的操作/任务。导航栏实现了一个按钮来返回堆栈中的上一个视图,标签栏提供更突然的变化(例如从警报视图切换到计时器视图),工具栏真正用于操作(例如共享、说)而不是实际的“导航”。
Note:
If you come here and find that any of the links are broken, just search on "Human Interface Guidelines" to find the current documentation.
注意:
如果您来到这里发现任何链接已损坏,只需搜索“人机界面指南”即可找到当前文档。