How to make an custom button with an self-stretching image?
I slightly remember that there is an class which is capable of stretching an image in such a way, that the first x pixels and the last y pixels won't get stretched.
For example if you have an button image with r开发者_开发问答ound corners, you would want those round corners to stay intact while the middle part of that image gets stretched.
This is a feature of class UIImage
itself.
- (UIImage *)stretchableImageWithLeftCapWidth:(NSInteger)leftCapWidth topCapHeight:(NSInteger)topCapHeight
You can assign the resulting image to the appropriate property of UIButton
as required.
精彩评论