title: How to collapse an NSSplitView pane with animation while using Auto Layout?
body: <p>I've tried everything I can think of, including all the suggestions I've found here on SO and on other mailing lists, but I cannot figure out how to programmatically collapse an <code>NSSplitView</code> pane with an animation while Auto Layout is on.</p>
  
  <p>Here's what I have right now (written in Swift for fun), but it falls down in multiple ways:</p>
  
  <pre><code>@IBAction func toggleSourceList(sender: AnyObject?) {
      let isOpen = !splitView.isSubviewCollapsed(sourceList.view.superview!)
      let position = (isOpen ? 0 : self.lastWidth)
  
      if isOpen {
          self.lastWidth = sourceList.view.frame.size.width
      }
  
      NSAnimationContext.runAnimationGroup({ context in
          context.allowsImplicitAnimation = true
          context.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseIn)
          context.duration = self.duration
  
          self.splitView.setPosition(position, ofDividerAtIndex: 0)
      }, completionHandler: { () -&gt; Void in
      })
  }
  </code></pre>
  
  <p>The desired behavior and appearance is that of Mail.app, which animates really nicely.</p>
  
  <p>I have a full example app available at <a href="https://github.com/mdiep/NSSplitViewTest">https://github.com/mdiep/NSSplitViewTest</a>.</p>