Skip navigation.
 
mlCALayer doesn't resize immediately
FROM : Axel Péju
DATE : Wed Nov 07 10:58:54 2007

Hi,

I've been experiencing some problems with Core Animation when resizing 
a view containing CALayers. I've made a simple project that shows the 
issue.

http://pacificturtle.free.fr/CoreAnimation.zip

Or here is the code:

- (id)initWithFrame:(NSRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
       rootLayer = [CALayer layer];
       rootLayer.backgroundColor = [CAView color:C_BLACK];
       rootLayer.layoutManager = [CAConstraintLayoutManager layoutManager];
       
       CALayer *sublayer = [CALayer layer];
       sublayer.backgroundColor = [CAView color:C_GRAY];
       [sublayer addConstraint:[CAConstraint 
constraintWithAttribute:kCAConstraintMinX
                                                 
relativeTo:@"superlayer"
                                                 
attribute:kCAConstraintMinX]];
                                               
       [sublayer addConstraint:[CAConstraint 
constraintWithAttribute:kCAConstraintWidth
                                                 
relativeTo:@"superlayer"
                                                 
attribute:kCAConstraintWidth]];
                                               
       [sublayer addConstraint:[CAConstraint 
constraintWithAttribute:kCAConstraintMidY
                                                 
relativeTo:@"superlayer"
                                                 
attribute:kCAConstraintMidY]];
                                               
       [sublayer addConstraint:[CAConstraint 
constraintWithAttribute:kCAConstraintHeight
                                                 
relativeTo:@"superlayer"
                                                 
attribute:kCAConstraintHeight]];
                                               
       [rootLayer addSublayer:sublayer];
   }
   return self;
}

The rootLayer is filled with black and its sublayer is filled with 
gray. This sublayer should resize itself to fill the rootLayer but 
when I resize the window, it takes some time for the gray layer to 
resize. Is this a bug or am I doing anything wrong ?

I am using a Powerbook G4 with a retail Leopard version.

Thanks

Axel

Related mailsAuthorDate
mlCALayer doesn't resize immediately Axel Péju Nov 7, 10:58
mlRe: CALayer doesn't resize immediately Thomas Schlömer Nov 7, 11:08
mlRe: CALayer doesn't resize immediately Axel Péju Nov 7, 21:52
mlRe: CALayer doesn't resize immediately Bertrand Landry-He… Nov 8, 12:42
mlRe: CALayer doesn't resize immediately Scott Anguish Nov 8, 23:11
mlRe: CALayer doesn't resize immediately Scott Anguish Nov 8, 23:11
mlRe: CALayer doesn't resize immediately Bertrand Landry-He… Nov 11, 09:17