How to make buttons with custom shapes?

喜你入骨 提交于 2020-01-13 11:52:45

问题


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?


回答1:


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.

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?



来源:https://stackoverflow.com/questions/6571294/how-to-make-buttons-with-custom-shapes

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!