[英]How to change background image of the UIButton in Interface Builder and preserve its shape?
I'm in the process of writing my first Hello World
application for iOS, and I don't know even elementary things, so I'm sorry if this question will be stupid. 我正在编写第一个iOS的
Hello World
应用程序,并且我什至不了解基础知识,因此对于这个问题是否很愚蠢,我感到抱歉。 I want to change the background image of button. 我想更改按钮的背景图像。 But when I do this button changes its shape and becomes squared instead of
Rect Square
(with non-zero corner radius). 但是,当我这样做时,此按钮将更改其形状并变为正方形,而不是
Rect Square
(角半径为非零)。 So the question are there some ways to change background and preserve button's shape either directly by Interface Builder or by manipulating XML-like language in .xib
files or whatever other way. 因此,问题是有一些方法可以直接通过Interface Builder或通过在
.xib
文件中使用类似XML的语言来更改背景并保留按钮的形状,或者采用其他方法。
Add a button and set its type property to custom. 添加一个按钮并将其type属性设置为custom。 With this method you could define an image for the button as you would like it to be displayed not just the background within the rounded rect.
使用此方法,您可以为按钮定义图像,因为您希望它显示的不仅仅是圆角矩形中的背景。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.