Skip navigation.
 
mlRe: how do i get a badged app icon?
FROM : Jeremy Dronfield
DATE : Sun Oct 17 15:33:03 2004

On 17 Oct 2004, at 12:22 am, Ken Victor wrote:

> under some circumstances, i need to display an app modal critical
> alert. this alert needs to have more than just a title and a message
> as it needs to include a picture.
>
> currently, i have this working as described below, but it seems to me
> that there is probably a much more direct and better approach.


I'm not entirely clear what you want, but it sounds like you just want
the badged icon image, rather than actually badging your app's icon
(for display in the dock, say). You could try something like this:

NSImage *appImage = [NSImage imageNamed:@"MyAppIcon"];

NSImage *badge = [NSImage imageNamed:@"MyBadgeImage"];
[badge setScalesWhenResized:YES];
[badge setSize:NSMakeSize(64, 64)];
       
[appImage lockFocus];
[badge compositeToPoint:NSMakePoint(aPointX, aPointY)
operation:NSCompositeSourceOver];
[appImage unlockFocus];

[myImageView setImage:appImage];

Of course, you'll want to play with the sizing and placement of the
badge to get it right. And you'll need to "borrow" a badge image from
somewhere. If you want to badge the actual icon as it appears in the
dock, app switcher etc, then use [NSApp
setApplicationIconImage:appImage].

Hope this helps.

Regards,
Jeremy

Related mailsAuthorDate
mlhow do i get a badged app icon? Ken Victor Oct 17, 01:22
mlRe: how do i get a badged app icon? Jeremy Dronfield Oct 17, 15:33