xcode 如何减少视图 iPhone 上的日期选择器控件的大小

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4264563/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 19:56:46  来源:igfitidea点击:

How to Reduce the size of date Picker control on view iPhone

iphonexcode

提问by SOF

I am working on Date Picker and facing a problem of customizing the size .How to reduce the size for date picker for example height.

我正在研究日期选择器并面临自定义尺寸的问题。如何减小日期选择器的尺寸,例如高度。

回答by Gene Goykhman

Some of the iOS standard controls, like the date picker, have very limited customization options available. I do not believe, for example, that you can change the height. You could develop your own date picker control (if you wanted it to look like a little calendar, for example, you would have to do that anyway). But consider some of the advantages of using the standard control exactly as it is:

某些 iOS 标准控件(例如日期选择器)的可用自定义选项非常有限。例如,我不相信您可以更改高度。您可以开发自己的日期选择器控件(例如,如果您希望它看起来像一个小日历,无论如何您都必须这样做)。但是,请考虑完全按原样使用标准控件的一些优点:

  1. Less work than writing your own
  2. Already familiar to most iOS users so there won't be usability issues
  3. Very polished look and feel (for example, animations and sound effects)
  4. Sizing and dimensions are already tested to work well for a touch interface
  1. 比自己编写更少的工作
  2. 大多数 iOS 用户已经熟悉,因此不会出现可用性问题
  3. 非常精美的外观和感觉(例如,动画和声音效果)
  4. 尺寸和尺寸已经过测试,适用于触摸界面

And so on.

等等。

回答by Ishu

Gene says correctly ,

基因说得对,

Use standerd controls if you have any problem such as covering your control by the date picker view then resize your view and animate the view(change y coordinate for the view).

如果您有任何问题,例如用日期选择器视图覆盖您的控件,然后调整视图大小并为视图设置动画(更改视图的 y 坐标),请使用标准控件。

May this help you to short out your problem.

愿这能帮助您解决问题。

回答by Farini

There's another solution here. You can make it look smaller by using views on top of it. If it's the view you want to customize then you can copy everything, throw it on photoshop, redraw it and then throw your new "customized view" on top of the datePicker. Many developers are doing that actually with the standard picker. It takes a couple more programming lines to do that but you can make it look great with some visual effort... Just a suggestion.

这里有另一个解决方案。您可以通过在其顶部使用视图来使其看起来更小。如果这是您想要自定义的视图,那么您可以复制所有内容,将其扔到 photoshop 上,重新绘制它,然后将新的“自定义视图”扔到 datePicker 之上。许多开发人员实际上是使用标准选择器来做到这一点的。需要多几行编程才能做到这一点,但您可以通过一些视觉效果让它看起来很棒……只是一个建议。