0

I have the following view structure:

enter image description here

In the Date Stack View, I want to hide/unhide the Advanced Stack Viewin an animated way (like the height was reduced to zero). I searched a lot for a solution and I came up with this:

dateStackView.wantsLayer = true
NSAnimationContext.runAnimationGroup({ context in

        context.duration = 0.5
        context.allowsImplicitAnimation = true
        advancedDateStackView.animator().isHidden = true
        self.view.layoutSubtreeIfNeeded()

        }, completionHandler: nil)

But it does not work --> no animation However, if I replace: advancedDateStackView.animator().isHidden = true by advancedDateStackView.animator().alphaValue = 0, I can see a fadeout animation for the advancedDateStackView. Which is not the desired behaviour, but proves the animation can work.

I also tried self.advancedDateStackView.animator().frame.size.height = 0 but no animation either.

Any help would be appreciated, I struggle to find a solution.

Thanks!!

EDIT to answer the comment below saying my question is a duplicate: Here my code works and allows me to perform a transition with alphaValue. However, what I need, and what does not work, is to perform a transition on isHidden.

vomi
  • 993
  • 8
  • 18
  • Possible duplicate of [Cocoa: NSView Animation](https://stackoverflow.com/questions/25456080/cocoa-nsview-animation) – Willeke Jul 18 '19 at 13:57
  • No it is not a duplicate. As I mention in the question, the animation works with the alphaValue parameter, but not with the isHidden ... – vomi Jul 18 '19 at 14:13

0 Answers0