xcode 如何制作可滚动的 TabBar...?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8957220/
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
How can I make a scrollable TabBar...?
提问by Jameel
I'm working on an app that needs many TabBar Items (6 or 7). I don't think users like to click the "More" button on TabBars, so I'm wondering how to make my own TabBar that slides from left to right, so one can easily access all the buttons on the tabbar without pressing "More."
我正在开发一个需要许多 TabBar 项目(6 或 7)的应用程序。我认为用户不喜欢点击 TabBars 上的“更多”按钮,所以我想知道如何制作我自己的从左向右滑动的 TabBar,这样人们就可以轻松访问标签栏上的所有按钮而无需按“更多” .”
Thanks!
谢谢!
回答by rob mayoff
I agree with the other answer that it's a bad idea from a design standpoint.
我同意另一个答案,从设计的角度来看这是一个坏主意。
Nevertheless, the technical answer is that you can simply embed a UITabBar
in a UIScrollView
. If you set the tab bar's width and the scroll view's contentSize
appropriately, the tab bar will be scrollable. You will probably want to turn off bouncing and scroll indicators.
尽管如此,技术上的答案是您可以简单地将 a 嵌入UITabBar
到UIScrollView
. 如果您contentSize
适当地设置了标签栏的宽度和滚动视图,标签栏将是可滚动的。您可能想要关闭弹跳和滚动指示器。
I didn't try it with a UITarBarController
.
我没有用UITarBarController
.
回答by Warren Burton
Opinions on whether this is a good idea or not aside
关于这是否是一个好主意的意见
A simple carousel should be fairly simple to implement from scratch using a UIScrollView with UIButton subviews. which will provide all the scroll mechanics for you
使用带有 UIButton 子视图的 UIScrollView 从头开始实现一个简单的轮播应该相当简单。这将为您提供所有滚动机制
As a sample idea.
作为一个示例想法。
- A UISCrollView which spans the width of the device.
- N buttons across the scroll content pane
- Restrict scroller to horizontal scrolling.
- Provide selected and unselected images for the buttons
- Create glue code to ensure only one button is selected at a time (like Radio buttons)
- 跨越设备宽度的 UISCrollView。
- 滚动内容窗格中的 N 个按钮
- 将滚动条限制为水平滚动。
- 为按钮提供选中和未选中的图像
- 创建粘合代码以确保一次只选择一个按钮(如单选按钮)
But I do agree with the other posters that its a bad UI idea. Id be thinking UIToolbar for this.
但我确实同意其他海报,这是一个糟糕的 UI 想法。我正在考虑为此使用 UIToolbar。
回答by sergio
Apart from considerations about UX and UI guidelines, a way you can implement such thing is implementing a tab bar from scratch. You can even find a tutorial herefor iOS5.
除了对 UX 和 UI 指南的考虑之外,实现此类事情的一种方法是从头开始实现标签栏。您甚至可以在此处找到适用于 iOS5的教程。
Actually, implementing a tab bar and a tab bar controller is not difficult as it may appear at first sight, but given the effort involved, you could also ask you what value this kind of design add to your app and to the user experience.
实际上,实现一个标签栏和一个标签栏控制器并不困难,因为它可能乍一看,但考虑到所涉及的工作,您还可以问您这种设计为您的应用程序和用户体验增加了什么价值。
In any case, if you decide to go for this path (a scrollable tab bar), I would suggest to make it such that the user cannot be misguided into thinking it's a standard tab bar.
在任何情况下,如果您决定采用此路径(可滚动标签栏),我建议您这样做,以免误导用户认为它是标准标签栏。
回答by Peter W.
That's against about every design guideline ever written for iOS.
这违背了为 iOS 编写的每一个设计指南。
(I know that Gift Plan for iOS has a scrollable tab bar, but it never hides items from the user.)
(我知道 iOS 的礼品计划有一个可滚动的标签栏,但它从不向用户隐藏项目。)
回答by Pradeep Kumar
The HOW to do it has been accepted,
已经接受了如何去做,
MOBILE DESIGN PATTERNS are not cast in concrete - it is about what is appropriate for YOUR app. It used to be that web pages scrolled vertically and side-scrolling was frowned on.
移动设计模式不是用混凝土浇铸的 - 它是关于什么适合您的应用程序。过去,网页垂直滚动,横向滚动不受欢迎。
But the tablet has been a game changer - people EXPECT to swipe side to side.
但平板电脑已经改变了游戏规则——人们期待左右滑动。
A comment on one case when scrolling tab view is actually highly appropriate ..
滚动选项卡视图时对一种情况的评论实际上非常合适..
(a) Look at xFeed in App Store This has 10+ topics like News Sports ... , easy to scroll to topic and click takes you to RSS feeds under it. This is truly convenient for user, and in my opinion appropriate. The alternative is to go back and forth between a menu of some kind and the target view - which could be a 2nd option, but from a quick browse experience this is good.
(a) 在 App Store 中查看 xFeed 这有 10 多个主题,例如 News Sports ... ,易于滚动到主题并单击将您带到其下的 RSS 提要。这对用户来说真的很方便,在我看来也是合适的。另一种方法是在某种菜单和目标视图之间来回切换——这可能是第二个选项,但从快速浏览体验来看,这很好。
(b) USA Today is another example - even on its main website, has the < > arrows to scroll between topics or you can click on tabs at top. Admittedly the tabs themselves don't scroll, but you get the idea. The entire site, and the mobile experience for USA Today is strongly optimized around side swipeing between chapters.
(b) 今日美国是另一个例子 - 即使在其主网站上,也有 < > 箭头可以在主题之间滚动,或者您可以单击顶部的选项卡。诚然,标签本身不会滚动,但您明白了。整个网站以及《今日美国》的移动体验都围绕章节之间的横向滑动进行了强烈优化。
(c) Presentations and content sites have come to be side scrolling as well.
(c) 演示文稿和内容站点也开始横向滚动。
(d) FINALLY on a Human Happiness viewpoint! People WANT TO TOUCH and PLAY with their mobile stuff. Not just tap! So mobile touch is quite happy here. One more thing to swipe and slide :)
(d) 最后是人类幸福的观点!人们想要触摸和玩他们的移动设备。不只是轻拍!所以移动触摸在这里很开心。还有一件事要滑动和滑动:)
回答by Anex
Here is a link of project with custom scrollable tab bar:
这是带有自定义可滚动标签栏的项目链接:
github - scrollable tab bar by BananaDev
It's free and provides a wide variety of customization options allowing you to fully change control.
它是免费的,并提供多种自定义选项,让您可以完全更改控制。