How do you move a CALayer instantly (without animation)
You want to wrap your call in the following:
[CATransaction begin]; [CATransaction setValue: (id) kCFBooleanTrue forKey: kCATransactionDisableActions];layer.position = CGPointMake(x, y);[CATransaction commit];
Swift 3 Extension :
extension CALayer { class func performWithoutAnimation(_ actionsWithoutAnimation: () -> Void){ CATransaction.begin() CATransaction.setValue(true, forKey: kCATransactionDisableActions) actionsWithoutAnimation() CATransaction.commit() }}
Usage :
CALayer.performWithoutAnimation(){ someLayer.position = newPosition}
You can also use the convenience function
[CATransaction setDisableActions:YES]
as well.
Note: Be sure to read the comments by Yogev Shelly to understand any gotchas that could occur.