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 can I set the backgroundColor
without animation?
相关问题
- CALayer - backgroundColor flipped?
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- how do you prevent page scroll in textarea on mobi
- Custom UITableview cell accessibility not working
相关文章
- Could I create “Call” button in HTML 5 IPhone appl
- Unable to process app at this time due to a genera
- How do you detect key up / key down events from a
- “Storyboard.storyboard” could not be opened
- Open iOS 11 Files app via URL Scheme or some other
- Can keyboard of type UIKeyboardTypeNamePhonePad be
- Can not export audiofiles via “open in:” from Voic
- XCode 4.5 giving me “SenTestingKit/SenTestKit.h” f
Swift
There are a couple other Swift answers here already, but I think this is the most basic answer:
I've taken Ben's answer and made a Swift helper function, here it is in case it'll be useful for anyone:
Stop implicit animation on a layer in swift:
Remember to set the delegate of your CALayer instance to an instance of a class that at least extends NSObject. In this example we extend NSView.
You can wrap the change in a
CATransaction
with disabled animations:If you want to disable implicit animations for a property completely, you can do so by assigning to the
actions
dictionary:If you wish to disable the implicit animation on a case by case basis, then using
[CATransaction setDisableActions:YES]
is still the better way to do it.