UIButton 不会转到 iPhone 中的 Aspect Fit [英] UIButton won't go to Aspect Fit in iPhone

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆