Disable animation when moving CALayers

后端 未结 2 848
南方客
南方客 2021-01-18 02:15

The following code animates the movement, even though I didn\'t use beginAnimations:context. How do I get it to move without animating? This is a new iphone vi

相关标签:
2条回答
  • 2021-01-18 03:09

    The simplest way to do it is to override the animation duration by putting the position code into a transaction:

    - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
        [CATransaction begin];
        [CATransaction setAnimationDuration:0];
        sublayer.position = [[touches anyObject] locationInView:self.view];
        [CATransaction commit];
    }
    
    0 讨论(0)
  • 2021-01-18 03:14

    More simplest way:

    sublayer.position = [[touches anyObject] locationInView:self.view];
    [sublayer removeAnimationForKey:@"position"];

    0 讨论(0)
提交回复
热议问题