dzpqzb
dzpqzb

Reputation: 191

How to disable the animation when changing the transform property of UIView?

As apple document said: 'transform Specifies the transform applied to the receiver, relative to the center of its bounds.

@property(nonatomic) CGAffineTransform transform

Discussion The origin of the transform is the value of the center property, or the layer’s anchorPoint property if it was changed. (Use the layer property to get the underlying Core Animation layer object.) The default value is CGAffineTransformIdentity.

Changes to this property can be animated. Use the beginAnimations:context: class method to begin and the commitAnimations class method to end an animation block. The default is whatever the center value is (or anchor point if changed)'

I don't need the animation ,how to disable the animation when changing the transform property of UIView?

Upvotes: 3

Views: 4375

Answers (2)

anlaital
anlaital

Reputation: 116

You can disable the implicit animations this way:

[CATransaction begin];
[CATransaction setDisableActions:YES];
// or if you prefer: [CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions];
// Your code here for which to disable the implicit animations.
[CATransaction commit];

https://developer.apple.com/library/ios/documentation/GraphicsImaging/Reference/CATransaction_class/Introduction/Introduction.html

Upvotes: 6

Pieter
Pieter

Reputation: 17705

It (should) only animate when you change the transform property inside e.g. UIView animateWithDuration: block.
I.e. disabling animation can be achieved by simply not changing the transform property inside an animation part of your code.

Can you post some code where you get animations that you didn't expect?

Upvotes: 1

Related Questions