NSAnimationContext的动画相当于iOS中的UIView动画。所以使用方法也大致差不多。比如设置一个位移的动画。
NSAnimationContext.beginGrouping()
let context = NSAnimationContext.current
context.duration = 10.0
context.timingFunction = CAMediaTimingFunction.init(name:.linear)
self.QRCodeBtn.animator().setFrameOrigin(NSPoint.init(x: 0, y: 0))
NSAnimationContext.endGrouping()
设置一个背景色渐变的动画
NSAnimationContext.beginGrouping()
let context = NSAnimationContext.current
context.duration = 10.0
context.timingFunction = CAMediaTimingFunction.init(name:.linear)
self.QRCodeBtn.animator().alphaValue = 0.0
NSAnimationContext.endGrouping()
网友评论