• 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
Re: Order of controls
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Order of controls


  • Subject: Re: Order of controls
  • From: Dave Batton <email@hidden>
  • Date: Fri, 29 Dec 2006 11:30:41 +0100

Ferhat,


I want to use an image as background of my window. But there is no way to say IB that the image should be draw first so that all controls can be shown.

As an option to Ricky and Sean's suggestions, you could also do something like this:


- (void) awakeFromNib
{
NSImage *backgroundImage = [NSImage imageNamed:@"background"];
NSColor *backgroundColor = [NSColor colorWithPatternImage:backgroundImage];
[_theWindow setBackgroundColor:backgroundColor];
}



This way you don't need to add another view and add all of the window's contents to that view. That can all go on one line, I just broke it up to make it a little easier to read here.


To get the background to update properly, you'll also need to do this in the window's delegate:

- (void)windowDidResize:(NSNotification *)aNotification
{
	[[_theWindow contentView] setNeedsDisplay:YES];
}


Cocoa is going to tile the image. If you want the image to scale or remain centered in the window, you'll need to update the background color image each time in the -windowDidResize: method.


Since Cocoa draws (and therefore tiles) from the lower-left corner of the window, it probably won't behave the way you'd want it to when resizing the window. I think you can get it to draw from the top-left corner by messing with the window's NSGraphicsContext, but I haven't figured out how to do that yet. Any help here would be appreciated.


-- Dave Batton Mere Mortal Software http://www.Mere-Mortal-Software.com/blog/


_______________________________________________

Cocoa-dev mailing list (email@hidden)

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


References: 
 >Order of controls (From: Ferhat Ayaz <email@hidden>)

  • Prev by Date: Re: Dock Icon and NSWindow.
  • Next by Date: Re: exclude from Window menu but show in Dock menu
  • Previous by thread: Re: Order of controls
  • Next by thread: Fixing NSSegmentedControl Display Bug
  • Index(es):
    • Date
    • Thread