Odd background image resizing on animating UIView
        Posted  
        
            by Woody
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Woody
        
        
        
        Published on 2010-06-10T23:56:08Z
        Indexed on 
            2010/06/11
            0:02 UTC
        
        
        Read the original article
        Hit count: 566
        
I have a UIView in the middle of a view that I am using as a game playing area (in a 2d cocoa view). This image has a background image of the same size as the view. Resizing the view I use animation to make it look smooth (and that works fine). However, when the animation starts, the background image immediately changes size, tiling or being clipped to a size that when the animation finishes, the background image is physically the same size.
I don't want this, I want the image to always fit the view, regardless of the view size.
    UIImage *bgImage = [UIImage imageNamed:@"head.png"];
... // resize the image returning another image
self.view.backgroundColor = [[UIColor alloc] initWithPatternImage:resizedImage];
[UIView beginAnimations:@"resizeView" context:nil];
[UIView setAnimationDuration:.5];
int localViewSize = ... // work out view sizes
self.view.frame = CGRectMake(... ,localViewSize,localViewSize); 
[UIView commitAnimations];
It looks very odd as it jumps to a different size, then animates to the original size.
I am guessing that maybe I would have to make a separate view underneath my main view but is that the only way?
© Stack Overflow or respective owner