本文介绍了如何为自定义类型UIButton设置矩形边框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想设置一个图像作为自定义UIButton的背景。我能够在界面构建器中为圆角矩形UIButton设置背景图像,但现在边框已经消失。有什么办法保留边界?
I am trying to set an image as the background of a custom UIButton. I was able to set a background image for the "rounded rect" UIButton in interface builder, but now the borders have vanished. Is there any way to retain the borders? Also, I would like to make the borders show up rectangular instead of rounded.
推荐答案
当您在按钮中设置背景图片时,按钮轮廓消失。如果您需要不同的大小,请在您的图片中包含它们。
When you set a background image in a button, the button outlines go away. Include them in your image, if you need different sizes look at the UIImage
stretchableImageWithLeftCapWidth:topCapHeight:
方法。
这篇关于如何为自定义类型UIButton设置矩形边框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!