索诺玛中的NSImageView动画回归?

NSImageView animation regression in Sonoma?

提问人:Yansen13 提问时间:11/12/2023 更新时间:11/12/2023 访问量:16

问:

在 macOS Sonoma 之前,我可以简单地对 NSImageView 大小和位置进行动画处理,如下所示:

    _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.

这按预期工作,图层和图像的位置和大小已更改,如上所述。 在Sonoma上,使用相同的应用程序,图层大小和位置仍会更改,但显示的图像大小保持不变。

有没有简单的方法可以解决这个问题?(我找不到有关该领域的索诺玛变化的任何信息......

我尝试了我能找到的所有可能影响这一点的东西:

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

但我根本无法真正改变这种新行为。

谢谢!

macOS Appkit CAANIMATION Quartz-Core NSMiamView

评论

0赞 Ian Bytchek 11/26/2023
你好!你有运气吗?在 Sonoma 上也遇到了奇怪的错误......😖
0赞 Yansen13 11/28/2023
@IanBytchek 很遗憾还没有。我必须先优先考虑另一个项目。

答: 暂无答案