• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Window animates width but not height
[Date Next][Thread Next][Date Index][Thread Index]

Window animates width but not height


  • Subject: Window animates width but not height
  • From: David Catmull <email@hidden>
  • Date: Mon, 2 Oct 2017 09:04:14 -0600

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 (email@hidden)

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:

This email sent to email@hidden

  • Next by Date: Programmatically create a file at ~/Downloads with animation
  • Next by thread: Programmatically create a file at ~/Downloads with animation
  • Index(es):
    • Date
    • Thread