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
基础教程推荐
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01