• 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: Adding Graphics to Buttons
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Adding Graphics to Buttons


  • Subject: Re: Adding Graphics to Buttons
  • From: Herr Witten <email@hidden>
  • Date: Sun, 1 Feb 2004 01:11:23 -0500

If it is a button, you can use setImage: However, I think there is
difficulty when you deal with a popup button or the like. In that
situation, I think you can simply set the image for a menu item or for
the first menu item, or you could simply subclass the button and treat
it as a view, implementing your own drawRect: method:

- (void)drawRect: (NSRect)rect
{
NSRect imageRect = NSMakeRect(0, 0, 0, 0);
imageRect.size = [_image size];

NSSize frameSize = [self frame].size;

[_image drawAtPoint: NSMakePoint(frameSize.width / 2, framSize.height
/ 2)
fromRect:imageRect operation: NSCompositeCopy fraction: 1.0];
}

On 1 Feb 2004, at 12:08 AM, Tom Gray wrote:

> I would like to add a simple graphic arrow pointing to the left or to
> the right to a button. Can anyone point me at some sample code of
> using a graphic with a button.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Adding Graphics to Buttons (From: Tom Gray <email@hidden>)

  • Prev by Date: Re: Invoking a Callback Selector (Newbie question)
  • Next by Date: Does NSImageView dispose of it's image
  • Previous by thread: Adding Graphics to Buttons
  • Next by thread: Re: Adding Graphics to Buttons
  • Index(es):
    • Date
    • Thread