iPhone animation with stretchable image

Posted by ryyst on Stack Overflow See other posts from Stack Overflow or by ryyst
Published on 2010-06-14T19:31:20Z Indexed on 2010/06/14 19:32 UTC
Read the original article Hit count: 151

Filed under:
|
|
|
|

I got a UIView subclass that draws a UIImage as its background. The image is created using the stretchableImageWithLeftCapWidth:topCapHeight: method, it has round edges.

I also use an animation block inside of which I resize my view. I had hoped that during animation, the drawRect:method would get called sometimes, which would result in the background image getting drawn correctly.

Unfortunately, the animation seems to render the image and then just rescale it during the animation, which obviously makes the formerly round edges getting nastily stretched.

The only workaround I can imagine is put three separate UIImageViews (top cap, middle fill, bottom cap) above my original background image and then reposition the caps images and scaling the fill image. However, this seems quite complicated...

Is there any better way I can prevent this from happening?

© Stack Overflow or respective owner

Related posts about iphone

Related posts about cocoa-touch