NSImageView animation regression in Sonoma?

38 Views Asked by At

Before macOS Sonoma I could simply animate NSImageView size and position like this:

    _imageView.wantsLayer = YES;
    CALayer *layer = _imageView.layer;
    
    [CATransaction begin];
    [CATransaction setValue:@(1.0) forKey:kCATransactionAnimationDuration];
    
    CABasicAnimation *boundsAnim = [CABasicAnimation animationWithKeyPath:@"bounds"];
    boundsAnim.fromValue = [NSValue valueWithRect:NSRectFromCGRect(layer.bounds)];
    boundsAnim.toValue = [NSValue valueWithRect:NSMakeRect(0, 0, 200, 200)];
    boundsAnim.duration = 1.0;
    [layer addAnimation:boundsAnim forKey:@"boundsAnim"];
    
    CABasicAnimation *posAnim = [CABasicAnimation animationWithKeyPath:@"position"];
    posAnim.fromValue = [NSValue valueWithPoint:NSPointFromCGPoint(layer.position)];
    posAnim.toValue = [NSValue valueWithPoint:NSMakePoint(200, 100)];
    posAnim.duration = 1.0;
    [layer addAnimation:posAnim forKey:@"posAnim"];
    
    [CATransaction commit];
    
    // now setting end-values, etc. pp.

This worked as expected, position and size of the layer AND image was changed as stated. On Sonoma, using the same app, the layer size and position is still changed, but the displayed image size stays unchanged.

Is there a simple way to fix this? (I could not find any info on Sonoma changes regarding this area ...)

I tried everything I could find that MIGHT affect this:

    layer.needsDisplayOnBoundsChange = YES;
    layer.contentsGravity = kCAGravityResizeAspectFill;
    view.layerContentsRedrawPolicy = NSViewLayerContentsRedrawDuringViewResize;

But I could not really change that new behaviour at all.

Thanks!

0

There are 0 best solutions below