How to prevent CALayer from implicit animations?

后端 未结 7 1581
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-25 14:59

When I set the backgroundColor property of an CALayer instance, the change seems to be slightly animated. But I don\'t want that in my case. How ca

7条回答
  •  佛祖请我去吃肉
    2020-12-25 15:20

    You can wrap the change in a CATransaction with disabled animations:

    [CATransaction begin];
    [CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions];
    //change background colour
    [CATransaction commit];
    

提交回复
热议问题