Adding text to NSImage using lockFocus/unlockFocus not working
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