• 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 color to an NSView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Setting color to an NSView


  • Subject: Re: Setting color to an NSView
  • From: "Alan Smith" <email@hidden>
  • Date: Fri, 8 Dec 2006 10:09:16 -0500

I'd do it like this:

- (void)drawRect:(NSRect)rect
{
 rect = [self bounds];
 [[NSColor blueColor] set];

 [self lockFocus];
 [NSBezierPath fillRect: rect];
 [self unlockFocus];
}

Perhaps that will fix it? In your code myRect should not be
hard-coded. It's better to use something like bounds to get the rect
you want. Or if you only want to fill a portion of the view use some
math to keep it dynamic.

Hope this helps.
Peace, Alan

--
// Quotes from yours truly -------------------------
"You don't forget, you just don't remember."
"Maturity resides in the mind."
"Silence is the Universe's greatest gift."
"When the World realizes that religion really is unnecessary, then it
shall evolve."
_______________________________________________

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


  • Follow-Ups:
    • Re: Setting color to an NSView
      • From: Shawn Erickson <email@hidden>
References: 
 >Setting color to an NSView (From: "vibhatha v" <email@hidden>)

  • Prev by Date: A good book to start with thats recent
  • Next by Date: Re: A good book to start with thats recent
  • Previous by thread: Re: Setting color to an NSView
  • Next by thread: Re: Setting color to an NSView
  • Index(es):
    • Date
    • Thread