I'm trying to get an auto layout constraint to update with animation inside an NSTableCellView
. The constraint is updating fine, but it's not happening with animation.
The following code is executed inside tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int)
:
NSAnimationContext.runAnimationGroup({ (context) in
context.allowsImplicitAnimation = true
context.duration = 0.3
cell.progressWidthConstraint.constant = CGFloat(progress)
cell.layoutSubtreeIfNeeded()
})
The cell
is my NSTableCellView
, and progressWidthConstraint
is the width constraint on an NSView
inside the cell.
Is there something special I need to do to get animation to work in a NSTableCellView
?
Can you try
NSAnimationContext.runAnimationGroup({ (context) in
context.allowsImplicitAnimation = true
cell.progressWidthConstraint.animator().constant = CGFloat(progress)
context.duration = 0.3
cell.layoutSubtreeIfNeeded()
})