UIButton不会在iPhone中使用Aspect Fit [英] UIButton won't go to Aspect Fit in iPhone
问题描述
我有几个UIButtons,在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屋!