I'm trying to animate an NSView by changing the value of its leading constraint.
This is my constraint object:
@IBOutlet weak var vModDatesLeading: NSLayoutConstraint!
and the code I am using to animate its position:
@IBAction func getModDates(_ sender: Any) {
NSAnimationContext.runAnimationGroup({ context in
//Indicate the duration of the animation
context.duration = 0.5
vModDatesLeading.constant = 0
vModDatesLeading.animator()
vModDatesWrapper.layoutSubtreeIfNeeded()
}, completionHandler:nil)
}
It is moving, but jumping, not animating. If this was iOS I would add:
view.layoutIfNeeded()
but that is not an option for NSView. I tried layoutSubtreeIfNeeded()
but that did nada.
Any help would be appreciated.