CATransaction completion being called immediately
Here is Swift 3.0.1, Xcode 8 version:
CATransaction.begin()
CATransaction.setCompletionBlock({
print("Transaction completed")
})
print("Transaction started")
view.layer.add(dropAndBounceAnimation, forKey: "appearance")
CATransaction.commit()
I'm not sure if this really is the correct fix, but by setting the completion-block before adding the animation for the layer, the completion-block is consistently called at the correct time.
[CATransaction begin];
[CATransaction setCompletionBlock:completionBlock];
[self.view.layer addAnimation:self.dropAndBounceAnimation forKey:@"appearance"];
[CATransaction commit];
You need to set the completion block before adding the animation.
[CATransaction begin];
[CATransaction setValue:[NSNumber numberWithFloat: 1.0f] forKey:kCATransactionAnimationDuration];
[CATransaction setCompletionBlock:^{
// ... whatever you want to do when the animation is complete
}];
[self.googleMapsView animateToCameraPosition:[GMSCameraPosition
cameraWithLatitude:LATITUDE
longitude:LONGITUDE
zoom:ZOOM]];
[CATransaction commit];
This must trigger the completion block after the completion of that animation on the view.