• 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
Adding text to NSImage using lockFocus/unlockFocus not working
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Adding text to NSImage using lockFocus/unlockFocus not working


  • Subject: Adding text to NSImage using lockFocus/unlockFocus not working
  • From: "Ashish Tiwari" <email@hidden>
  • Date: Tue, 24 Feb 2009 16:20:57 +0530

Hi All,



I am trying to get finder icon view like behavior in my application.  Using
IKImageBrowserView I am able to show icons for contents of a directory but I
also need file/directory name below those icons. For this I am trying to
insert NString into NSImage but text is now showing up in
IKImageBrowserView.



NSImage *img = [[NSWorkspace sharedWorkspace] iconForFile:[path
stringByAppendingPathComponent:file]];

//NSImage *img = [[NSImage
alloc]initWithContentsOfFile:@"/Users/ashisht/Desktop/downloads.png"];

NSString *imgID = [file lastPathComponent];

[img       setName:imgID];



 [img lockFocus];

NSFont *txtFont = [NSFont boldSystemFontOfSize:13];

NSDictionary *txtDict = [NSDictionary


dictionaryWithObjectsAndKeys:txtFont,

                                                NSFontAttributeName, nil];

NSString* myString = @"ABCDE";

 [myString drawAtPoint: NSMakePoint(0, 0) withAttributes: txtDict];



 [img unlockFocus];



Please tell me what I am doing wrong, is there any other way of attaching
text to NSImage (result should be NSImage)?

Note: IKImageBrowserView IB connections are proper also reloadData and other
delegates are working fine.



Thanks in advance.



Ashish Tiwari





_______________________________________________

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

  • Follow-Ups:
    • Re: Adding text to NSImage using lockFocus/unlockFocus not working
      • From: Michael Ash <email@hidden>
    • Re: Adding text to NSImage using lockFocus/unlockFocus not working
      • From: Graham Cox <email@hidden>
  • Prev by Date: Re: Moving oneself to /Applications (or ~/Applications)
  • Next by Date: how to modify 'PictureSharing' example?
  • Previous by thread: Re: Disabled, auto-disappearing placeholder in search field like Safari, Console.app
  • Next by thread: Re: Adding text to NSImage using lockFocus/unlockFocus not working
  • Index(es):
    • Date
    • Thread