如何使自定义形状的按钮? [英] How to make buttons with custom shapes?
问题描述
我正在开发,需要的按钮比为长方形如/平方,变形虫形按钮其他形状的iPhone应用程序。此外,单击该按钮时,该按钮只强调不亚于它的大小。所以只要设置背景图片仅是不够的。我应该怎么做呢?
I'm developing an iPhone app that requires buttons to be of shapes other than rectangles/squares for eg, an amoeba shaped button. Also, when the button is clicked, the button is highlighted only as much as its size. So just setting a background image only is not enough. How should I go about it?
推荐答案
的一种方法是使pre-渲染的图像为正常状态和选中状态。然后设置使用了setBackgroundImage:forState:
设置每个图像是适当的状态
One way would be to make pre-rendered images for both the normal state and selected state. Then set use setBackgroundImage: forState:
to set each image to it's appropriate state.
我要补充,你的pre-渲染图像将包括围绕变形虫形状的透明度,因此会给出一个变形虫形按钮的错觉。结合,与阿米巴形的选定状态的选定状态的形象,以及禁用highlightAdjustsImage应该给你你想要的结果。还是我还是误解的东西?
I should add, your pre-rendered images would include transparency around the "amoeba" shape and would therefore give the illusion of an "amoeba" shaped button. Combining that with a selected state image of the selected state of the "amoeba" shape as well as disabling highlightAdjustsImage should give you the result you desire. Or am I still misunderstanding something?
这篇关于如何使自定义形状的按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!