Flexible iPhone button
Is there a way 开发者_如何转开发to create a flexible iPhone button from a single graphic, like Android does with 9-patch drawables?
For example, would it be possible to use this graphic
to create a wider button?Yes. Load your image into a UIImage, then use stretchableImageWithLeftCapWidth:topCapHeight:
with appropriate parameters to build a copy of the image with hints about the proper end caps. You can then assign this new image to the button.
See UIImage Class Reference.
Yes, look into the UIImage method -stretchableImageWithLeftCapWidth:topCapHeight:
精彩评论