问题描述
我有一个 UIPickerView
我想改变框架的大小.似乎无论我想要它有多小,都设置了我不能小于的最小尺寸.我看过其他关于这个的帖子,但它们已经很旧了,现在代码也大不相同了.我知道如何调整选择器视图中行的高度和宽度,但不知道框架本身.即使在 Frame Inspector 中,无论我改变高度和宽度,它都不会小于特定尺寸.
I have a UIPickerView
that I would like to change the size of frame. It seems that no matter how small I want it there is set minimum size that I can't go smaller than. I have seen other posts about this but they are very old and the code is much different now. I know how to adjust the height and width of the rows in the picker view but not the frame itself. Even in the Frame Inspector no matter what I change on the height and width it will not go smaller than a certain size.
推荐答案
你不能在不做一些奇怪的黑客攻击的情况下改变 UIPickerView 的大小.该类是为特定尺寸编写的,如果您修改它以更改大小,则会导致奇怪的问题.
You can't change the size of a UIPickerView without doing strange hacks. The class is written for specific dimensions and if you do hack it to change the size it leads to weird issues.
我建议您使用 iCarousel 库 来实现自定义选择器视图.
I would suggest you use the iCarousel library to implement a custom picker view.
这篇关于在 Swift 中更改 UIPickerView 的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!