问题
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