UIButton won#39;t go to Aspect Fit in iPhone(UIButton 不会转到 iPhone 中的 Aspect Fit)
问题描述
我有几个 UIButton,在 IB 中它们设置为 Aspect Fit,但由于某种原因,它们总是在拉伸.你还有什么需要设置的吗?我尝试了所有不同的视图模式,但它们都不起作用,它们都是拉伸的.
I have a couple UIButtons, and in IB they're set to Aspect Fit, but for some reason they're always stretching. Is there something else you have to set? I tried all the different view modes and none of them work, they all stretch.
推荐答案
我以前也遇到过这个问题.我通过将我的图像放入 UIImageView
来解决它,其中 contentMode
设置实际上可以工作,并在其上放置一个透明的自定义 UIButton
.
I've had that problem before. I solved it by putting my image in a UIImageView
, where contentMode
settings actually work, and putting a transparent custom UIButton
over top of that.
这个答案已经过时了.请参阅 @Werner Altewischer 的答案,了解现代 iOS 版本中的正确答案.
This answer is obsolete. See @Werner Altewischer's answer for the correct answer in modern versions of iOS.
这篇关于UIButton 不会转到 iPhone 中的 Aspect Fit的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:UIButton 不会转到 iPhone 中的 Aspect Fit


基础教程推荐
- 如何使用 YouTube API V3? 2022-01-01
- Android文本颜色不会改变颜色 2022-01-01
- “让"到底是怎么回事?关键字在 Swift 中的作用? 2022-01-01
- 固定小数的Android Money Input 2022-01-01
- LocationClient 与 LocationManager 2022-01-01
- 如何使 UINavigationBar 背景透明? 2022-01-01
- Android ViewPager:在 ViewPager 中更新屏幕外但缓存的片段 2022-01-01
- 使用 Ryzen 处理器同时运行 WSL2 和 Android Studio 2022-01-01
- :hover 状态不会在 iOS 上结束 2022-01-01
- 在 iOS 上默认是 char 签名还是 unsigned? 2022-01-01