如何在更改UIView的transform属性时禁用动画?

dzp*_*qzb 2 animation objective-c uiview ios

正如apple文档所说:'transform指定应用于接收器的变换,相对于其边界的中心.

@property(非原子)CGAffineTransform变换

讨论变换的原点是center属性的值,或者如果更改了图层的anchorPoint属性.(使用layer属性获取基础Core Animation图层对象.)默认值为CGAffineTransformIdentity.

可以对此属性的更改进行动画处理.使用beginAnimations:context:class方法开始,使用commitAnimations类方法结束动画块.默认值是中心值(或者如果更改了锚点)'

我不需要动画,如何在更改UIView的transform属性时禁用动画?

小智 5

您可以通过以下方式禁用隐式动画:

[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];
Run Code Online (Sandbox Code Playgroud)

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