I'm able add a number of NSTextFields to an NSStackView using the following code:
optionsStackView.addView(newOption, in: .center)
The problem I'm encountering is getting each NSTextField (newOption) to appear one after another when the view appears - not all at once when using NSAnimationContext.runAnimationGroup { (context) in }
let stackViewSubViews = optionsStackView?.arrangedSubviews.enumerated()
stackViewSubViews!.forEach({ newOption in
NSAnimationContext.runAnimationGroup { (context) in
context.duration = 1
newOption.element.animator().alphaValue = 1
}
})
I basically need to delay for a half a second each time the for loop runs to show one NSTextField after another for all the NSTextFields but I can't quite figure out how to do this. I looked at using DispatchQueue.main.asyncAfter(deadline: .now() + 0.5)
but can't quite figure out the code to make this work without everything appearing all at once...
I'm sure I'm missing something simple here.
Can anyone please help?