I have been reading that Apple recommends to use block-based animations instead of CATransaction
Before, I was using this code to disable animations:
[CATransaction begin];
[CATransaction setDisableActions: YES];
// !!! resize
[CATransaction commit];
Is there a new recommended method to do this, or is this still okay?
I want to stop animation and remove hint label once user presses the text field to enter data. func removeAnimation(textField: UITextField) { view. layer. removeAllAnimations() self.
You don't need to use [weak self] in static function UIView. animate() You need to use weak when retain cycle is possible and animations block is not retained by self.
The contents of your block are performed on the main thread regardless of where you call [UIView animateWithDuration:animations:] . It's best to let the OS run your animations; the animation thread does not block the main thread -- only the animation block itself.
it queries the views objects for changed state and gets back the initial and target values and hence knows what properties to change and in what range to perform the changes. it calculates the intermediate frames, based on the duration and initial/target values, and fires the animation.
[UIView setAnimationsEnabled:NO];
//animate here
[UIView setAnimationsEnabled:YES];
For iOS 7 and above this can now be accomplished with:
[UIView performWithoutAnimation:^{
// Changes we don't want animated here
view.alpha = 0.0;
}];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With