gpt4 book ai didi

ios - CALayer 动画还原

转载 作者:行者123 更新时间:2023-11-29 13:15:59 24 4
gpt4 key购买 nike

我一直在尝试做 CALayer 动画。但是在动画之后它恢复了。我找到了一些解决方案,比如 removedOnCompleteion = YESfill mode = kCAFillModesForwards 但没有一个对我有帮助。这是代码。需要一点帮助,谢谢。

  void(^ myblock)(NSDictionary *) = ^(NSDictionary *dict){

NSMutableArray *arrOfPt= [dict objectForKey:@"Path"];

CGPoint p1 = [[arrOfPt objectAtIndex:0] CGPointValue];

CGPoint cp1 = [[arrOfPt objectAtIndex:1] CGPointValue];

// CGPoint cp1 = [[arrOfPt objectAtIndex:1] CGPointValue];
CGPoint cp2 = [[arrOfPt objectAtIndex:2] CGPointValue];
CGPoint p2 = [[arrOfPt objectAtIndex:3] CGPointValue];

NSMutableArray *arrayTime = [dict objectForKey:@"Time"];
CGFloat time = [[arrayTime objectAtIndex:0] floatValue];

pointerLayer.opacity = 1;
// NSArray *oneObjPt = [NSArray arrayWithObjects:[arrOfPt objectAtIndex:0],[arrOfPt lastObject],nil];
// NSArray *oneObjTime = [NSArray arrayWithObjects:[arrayTime objectAtIndex:0],[arrayTime lastObject],nil];
// NSArray *oneObjTime = [NSArray arrayWithObjects:[NSNumber numberWithFloat:0.0],[NSNumber numberWithFloat:1.0],nil];
CAKeyframeAnimation *keyFrameAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"];

// [keyFrameAnimation setCalculationMode:kCAAnimationPaced];
keyFrameAnimation.duration = 1;
keyFrameAnimation.removedOnCompletion = NO;
[keyFrameAnimation setFillMode:kCAFillModeForwards];

CGMutablePathRef fpath = CGPathCreateMutable();

CGPathMoveToPoint(fpath, NULL, p1.x, p1.y);
CGPathAddCurveToPoint(fpath, NULL, cp1.x, cp1.y, cp2.x, cp2.y, p2.x, p2.y);
keyFrameAnimation.path = fpath;

[pointerLayer addAnimation:keyFrameAnimation forKey:@"pos"];
CGPoint newLoc = pointerLayer.position;// this is just to verify the layer's location

最佳答案

I found a few solutions like removedOnCompleteion = YES and fill mode = kCAFillModesForwards

这些都不是解决方案。

CGPoint newLoc = pointerLayer.position;

那不会有任何好处;添加动画实际上并没有改变位置。动画稍后发生。

我不完全确定你在追求什么,但它可能会帮助你阅读我对 Core Animation 的解释。动画只是一种幻觉;这是一个用“表示层”玩的游戏。由真实层移动到动画之后的位置添加将出现的动画让它移动到那里。

我提供了一种公式化的方法来确保您的核心动画能够将您带到您想去的地方:

http://www.apeth.com/iOSBook/ch17.html#_using_a_cabasicanimation

关于ios - CALayer 动画还原,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15812350/

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