gpt4 book ai didi

cocoa - 删除 CALayer 内容属性的插值

转载 作者:行者123 更新时间:2023-12-03 16:33:51 24 4
gpt4 key购买 nike

重新提问:

当您为内容键添加动画时,显然会触发 CATransitionAnimation,它将原始内容属性淡入动画值数组中的第一个值,从而导致 0.25 秒的淡入淡出。而且看起来很糟糕!我已经使用此处讨论的所有方法抑制了每个可动画属性(通过委托(delegate)将空动画返回到 Action 字典中,使用 CATransaction),但这些似乎都不是针对这个特定的过渡动画。

alt text

我一直在研究什么属性(property)可能造成这种情况,但无法弄清楚。

我需要抑制向内容键添加动画时发生的过渡动画。

我实在是太不知所措了,所以我就把正在添加的关键帧动画放上来给大家看看。我想也许我在这里做错了什么?请注意,该数组只是 6 个 CGImageRef(动画帧)的数组。

+ (CAKeyframeAnimation *)moveLeftAnimation {

CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"contents"];
animation.values = [NSArray arrayWithArray:[Setzer walkingLeftSprite]];
animation.duration = 0.5f;
animation.keyTimes = [NSArray arrayWithObjects:
[NSNumber numberWithFloat:0.0],
[NSNumber numberWithFloat:0.2],
[NSNumber numberWithFloat:0.4],
[NSNumber numberWithFloat:0.6],
[NSNumber numberWithFloat:0.8],
[NSNumber numberWithFloat:1.0],
nil];
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
return animation;

}

另外,我有一个动画可以在 Sprite 的 Action 字典中处理位置键:

+ (CABasicAnimation *)moveAnimation {

CABasicAnimation *moveAnimation = [CABasicAnimation animation];
moveAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
moveAnimation.duration = 0.5f;

return moveAnimation;

}

我在想,当您更改图层的位置时,也许会发生这种转变?我不知道...

请帮忙!这让我发疯!

最佳答案

您可以按照我在this answer中描述的方式做一些事情,我通过在该图层的 actions 字典中设置适当的值来禁用各种图层属性的隐式动画。

就你而言,我相信类似的事情

NSMutableDictionary *newActions = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
[NSNull null], @"contents",
nil];
layer.actions = newActions;
[newActions release];

应阻止图层的 contents 属性的隐式动画,直到您显式为其设置动画。

关于cocoa - 删除 CALayer 内容属性的插值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4334330/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com