在 Swift 中更改 UIPickerView 的大小

编程入门 行业动态 更新时间:2024-10-28 19:25:27
本文介绍了在 Swift 中更改 UIPickerView 的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我有一个 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 的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-29 02:14:05,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1183560.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:大小   Swift   UIPickerView

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!