title: How to position progress spinner inside the title bar of a Mac application
body: <p>I am trying to place a progress spinner at the right side of the the title bar of the window of my Mac OS X application, but I can't do that with the Interface Builder, as it doesn't let me drag the view inside it.</p>
  
  <p>So, I tried to put it in the title bar programmatically, with the following code inside the <code>applicationDidFinishLaunching</code> method in AppDelegate.m:</p>
  
  <pre><code>loadingSpinner = [[NSProgressIndicator alloc] init];
  [loadingSpinner setFrame:NSMakeRect(485, 0, 17, 17)];
  [loadingSpinner setStyle:NSProgressIndicatorSpinningStyle];
  NSView *titleBarView = [[_window standardWindowButton:NSWindowCloseButton] superview];
  [titleBarView addSubview:loadingSpinner];
  </code></pre>
  
  <p>However, this is putting my progress spinner view at the bottom of the window instead of the title bar. It appears NSMakeRect() is positioning it relative to the bottom of the window, not the top.</p>
  
  <p>If I change the second parameter of NSMakeRect (y position) to something like 370, it puts the loading spinner in the place I want it to be, but obviously when I resize the window vertically, it brings the progress spinner together to the bottom.</p>
  
  <p>I've never seen something like this before. How can I fix that?</p>
  
  <p>P.S.: Also, I don't know if there's a "more right" way to get the title bar view. As you can see, I'm using the superview of the close button view to get it, which seems a bit "dirty". </p>