We will finish off this chapter by returning to NSView
, which also has animatable properties.
We will let the examples speak mostly for themselves. Often, it will be sufficient for us to apply animations to a view at this higher level, and the experience we have gained in animating CALayer
objects, together with the material covered in the previous chapter on Core Graphics, will make understanding this code reasonably easy.
Firstly, NSView
and its subclasses can also make use of implicit animations:
func NSViewImplicit() { NSAnimationContext.current().allowsImplicitAnimation = true NSAnimationContext.current().duration = 5.0 customView.animator().alphaValue = 0.0 }
Just a few points here:
- The first line of code is not actually necessary--implicit animations are enabled by default--but it shows how you would also disable implicit animations if the need should arise
- We do, however, need to set the
duration
property of theNSAnimationContext
to be more than...