I have a preferences window with a NSTabViewController hooked up to the
toolbar for selecting tabs. I want the window to be resizable, and to
resize iself if necessary when switching tabs to fit the new tab's size.

I'm subclassing NSTabViewController with the following overload:

override var selectedTabViewItemIndex: Int
{
  didSet
  {
    guard let view = tabViewItems[selectedTabViewItemIndex].view,
          let window = view.window
    else { return }

    let minSize = view.fittingSize
    let contentRect = NSWindow.contentRect(forFrameRect: window.frame,
                                           styleMask: window.styleMask)
    let minRect = NSRect(origin: contentRect.origin, size: minSize)
    let newRect = minRect.union(contentRect)
    let newFrame = NSWindow.frameRect(forContentRect: newRect,
                                      styleMask: window.styleMask)

    window.animator().setFrame(newFrame, display: true, animate: true)
  }
}
The result is that it animates resizing horizontally, and at the end of the
animation it suddenly resizes vertically as well. How do I get it to just
animate both directions at once?

Note - I posted this question to Stack Overflow a few days ago, but haven't
gotten any responses. Feel free to respond there if you'd like the rep
points :)  https://stackoverflow.com/q/46493460/310159
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to