I have a UIButton with the specified width of 200. The autoresizingMask property is autoresizingMask to UIViewAutoresizingFlexibleWidth . The UIImage attribute is applied to this backgroundImage button. This UIImage is defined as follows:
[[UIImage imageNamed:@"buttonimage.png"] stretchableImageWithLeftCapWidth:10 topCapHeight:0]
buttonimage.png has a width of 400 pixels (2x the width of the button, due to the resolution of the retina) and is a rounded rectangle. In portrait mode, everything is in order. As soon as the user rotates the device and the iPhone enters landscape mode, UIButton stretched. Due to this behavior, the left rounded border of the image remains unchanged ( stretchableImageWithLeftCapWidth: , but the right corners are also stretched. Is there any property that I forgot to set to ensure that only one specified pixel (for example, the tenth) is stretched, and everything else retains its size?
Thanks in advance!
Edit: if I use a smaller image that is already stretched in portrait mode, both borders seem to expand.
Solved! If your image is called "myImage.png" and this is the retina version, just name it " myImage@2x.png "
source share