Search code examples
iosiphonexcodecalayer

xcode: Does CALayer erase (blank) its previous image when I change its size?


I'm trying to show a bar graph that goes up and down. But when I run it, it only updates display when bar graph increases, as if Objective-C is not erasing the previous CALayer's image.

If the CALayer's .frame is set smaller, does it automatically erase the previous image?

Here's how I update it:

    [ CATransaction begin ]; 
[CATransaction setValue : ( id ) kCFBooleanTrue forKey : kCATransactionDisableActions]; 
graph_CALayer.frame = CGRectMake( left_x, top_y, width, height );
graph_CALayer.backgroundColor = bar_background_color.CGColor;
[CATransaction commit];

Solution

  • No, it does not erase previous image. My frame arguments were wrong. y coordinate = 0 is at top of my bar graph, which confuses me time again. To be a better iOS programmer, maybe I should stand on my head. :-)