简体   繁体   English

具有5-6个细分的UISegmentedControl

[英]UISegmentedControl with 5-6 segments

In our application we are showing the segmented control with dynamic segments. 在我们的应用程序中,我们展示了带有动态段的分段控件。

If number of segments is 2-3 we have no issue, but if number of segments is 5 or more than that then the text in segment is not readable. 如果段数是2-3,则没有问题,但是如果段数是5或大于5,则段中的文本不可读。

分段控制

See the above image. 参见上图。

So, what is the alternate way to resolve this issue? 那么,解决此问题的另一种方法是什么?

There are a couple of solutions. 有两种解决方案。

  1. You could use a UIPickerView instead of a UISegmentedControl 您可以使用UIPickerView代替UISegmentedControl
  2. You could show three segments, where the first two segments are the most often used segments, and touching the third segment shows a UIPickerView with all the options. 您可以显示三个分段,其中前两个分段是最常用的分段,触摸第三个分段将显示带有所有选项的UIPickerView。
  3. You could embed the UISegmentedControl in a UIScrollView. 您可以将UISegmentedControl嵌入UIScrollView中。 Make sure to size your segmented control in a way that shows that it is indeed scrollable. 确保以显示确实可滚动的方式调整分段控件的大小。

Which one fits best depends on your app, and what is the actual use of those segments. 哪一个最适合取决于您的应用,以及这些细分的实际用途是什么。

It's hard to answer this question on a general basis. 总体上很难回答这个问题。 Apple's Human Interface Guidlines may be a good reference for this kind of issues. 苹果公司的人机界面指南可能是此类问题的很好参考。

最好的解决办法是,增加ScrollView在您的视图控制器 ,并添加UISegmentControllerUIScrollView ,给你的部分按钮的修复尺寸和改变的大小UISegmentController基础上按钮的数量总 ,改变的内容大小UIScrollView的基础UISegmentController

try setting font size for the test to be smaller, that ways, the text will be more visible. 尝试将测试的字体大小设置为较小,这样文本将更加可见。 However, if your number of segments keep increasing, that wouldn't be a solution 但是,如果您细分的数量持续增加,那将不是解决方案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM