• 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: Setting A Background Image On A Window
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Setting A Background Image On A Window


  • Subject: Re: Setting A Background Image On A Window
  • From: "Michael Ash" <email@hidden>
  • Date: Wed, 10 Dec 2008 23:43:44 -0500

On Wed, Dec 10, 2008 at 4:47 PM, Neil <email@hidden> wrote:
> I've googled around and poked at the documentation in Xcode, but I can't
> seem to find any references to this.  I'm trying to do something like
> setBackgroundColor, but instead of picking a color, I want to pick an image.
>
> The end goal is to program an emulator for a small medical device like an
> insulin pump; so the background of the window would be an image of the
> device, and then I'd put some buttons and fields and such on top.

Create a borderless NSImageView or a basic NSView subclass with
appropriate code in drawRect: and make it fill the window. Then either
send it to the back of all your other views (if you're requiring
10.5+) or make all of your other views subviews of this view (if you
need 10.4 compatibility or otherwise run into trouble with the other
approach) and there you go.

Brandon's idea of using +colorWithPatternImage: is a good one too. The
two approaches have different upsides and downsides, this is just an
alternative.

Mike
_______________________________________________

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

References: 
 >Setting A Background Image On A Window (From: Neil <email@hidden>)

  • Prev by Date: Re: CoreData -- addPersistentStoreWithType crashing [solved]
  • Next by Date: Prolem with CalCalendar programming
  • Previous by thread: Re: Setting A Background Image On A Window
  • Next by thread: Starting Cocoa apps from the command line
  • Index(es):
    • Date
    • Thread