【发布时间】:2021-07-03 10:07:24
【问题描述】:
我正在尝试通过更改其前导约束的值来为 NSView 设置动画。
这是我的约束对象:
@IBOutlet weak var vModDatesLeading: NSLayoutConstraint!
以及我用来为其位置设置动画的代码:
@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)
}
它在移动,但在跳跃,而不是动画。如果这是 iOS,我会添加:
view.layoutIfNeeded()
但这不是 NSView 的选项。我试过layoutSubtreeIfNeeded(),但没用。
任何帮助将不胜感激。
【问题讨论】:
标签: swift macos animation nsview