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
基础教程推荐
- Play 商店的设备兼容性问题 2022-01-01
- 为什么姜饼模拟器方向卡在应用程序中? 2022-01-01
- 如何比较两个 NSDate:哪个是最近的? 2022-01-01
- UIImage 在开始时不适合 UIScrollView 2022-01-01
- 如何将图像从一项活动发送到另一项活动? 2022-01-01
- SwiftUI-ScrollViewReader的ScrollTo不滚动 2022-01-01
- iOS - UINavigationController 添加多个正确的项目? 2022-01-01
- Xcode UIView.init(frame:) 只能在主线程中使用 2022-01-01
- navigationItem.backBarButtonItem 不工作?为什么上一个菜单仍然显示为按钮? 2022-01-01
- Android Volley - 如何动画图像加载? 2022-01-01
