Reputation: 9791
I got a view subclass with the following drawRect:
method:
- (void)drawRect:(CGRect)rect {
[myBackgroundImage drawInRect:rect];
... // more, complex drawing such as strings, lines, etc.
}
I want to animate a background image transition to another background image, while the rest of the view drawn above the background image remains the same. How would I do that? Will I need an additional CALayer
?
Upvotes: 0
Views: 300
Reputation: 13164
It looks like you might use multiple layers: one for each background and another for the rest in the foreground. So that you can apply animations and transformations on each layer separately. This is a solution that I have been succesfully using in Flex with Sprites: organized a display list using separated graphical objects layered one above another and moving/rotating/fading and whatever applied to any of them.
As a design principle it should work in all graphical environments including iOS.
The one thing to take into account: transformations applied on the superlayer of the children layers affect all sublayers at once.
Upvotes: 1