我看到很多人用它来禁用隐式动画:
[CATransaction begin];
[CATransaction setDisableActions:YES];
someLayer.backgroundColor = someCGColor;//no animation
[CATransaction commit];
Run Code Online (Sandbox Code Playgroud)
但没有CATransaction开始和提交它也有效:
[CATransaction setDisableActions:YES];
someLayer.backgroundColor = someCGColor;//no animation
Run Code Online (Sandbox Code Playgroud)
像这样它也有效:
[CATransaction setDisableActions:YES];
someLayer1.backgroundColor = someCGColor;//no animation
[CATransaction setDisableActions:NO];
someLayer2.backgroundColor = someCGColor2; //have animation
Run Code Online (Sandbox Code Playgroud)
所以问题是,为什么我需要使用CATransaction begin&commit?有什么情况我必须使用它们吗?
谢谢,Aunn.