Re: IKImageBrowserView Title & Subtitle Woes
Re: IKImageBrowserView Title & Subtitle Woes
- Subject: Re: IKImageBrowserView Title & Subtitle Woes
- From: thomas goossens <email@hidden>
- Date: Sun, 13 Apr 2008 22:50:44 +0200
Hi Thaddeus,
To change the title attributes, use setValue:forKey with the key
"IKImageBrowserCellsTitleAttributesKey" and pass a dictionary that
contains the text attributes.
To get the list of keys for the attribute dictionary see the section
"standard attributes" of the following page:
http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSAttributedString_AppKitAdditions/Reference/Reference.html
With attributes you can set the text alignment, line break mode, font,
color...
NSMutableParagraphStyle *paragraphStyle = [[[NSMutableParagraphStyle
alloc] init] autorelease];
[paragraphStyle setLineBreakMode:NSLineBreakByTruncatingTail];
[paragraphStyle setAlignment:NSCenterTextAlignment];
NSMutableDictionary attributes = [[NSMutableDictionary alloc]
initWithCapacity:3];
[attributes setObject:[NSFont fontWithName:@"Lucida Grande" size:12]
forKey:NSFontAttributeName];
[attributes setObject:paragraphStyle
forKey:NSParagraphStyleAttributeName];
[attributes setObject:[NSColor colorWithDeviceRed:0 green:0 blue:0
alpha:1] forKey:NSForegroundColorAttributeName];
[_imageBrowser setValue:attributes
forKey:IKImageBrowserCellsTitleAttributesKey];
[attributes release];
If you just want to change the color and keep other settings unchanged
you can do this: (I never tried it but that should work ;)
NSDictionary *oldAttributes = [_imageBrowser valueForKey:
IKImageBrowserCellsTitleAttributesKey];
NSMutableDictionary *newAttributres = [oldAttributes mutableCopy];
[attributes setObject:[NSColor colorWithDeviceRed:1 green:0 blue:0
alpha:1] forKey:NSForegroundColorAttributeName];
[_imageBrowser setValue: newAttributres
forKey:IKImageBrowserCellsTitleAttributesKey];
[newAttributres release];
-- Thomas.
On Apr 13, 2008, at 10:01 PM, Thaddeus Cooper wrote:
Hello all.
I am trying to set the color of the title and subtitle in an
IKImageBrowserView. From what I see in the documentation I need to
set up a dictionary with key-value pairs that describe the
attributes of what I want to set it to. I have the snippet of code
that I'm trying to use below:
NSDictionary *titleTextInfo = [NSDictionary dictionaryWithObject:
[CIColor colorWithRed:0.0 green:1.0 blue:0.0] forKey:@"titleColor"];
[myBrowserView setValue:titleTextInfo
forKey:IKImageBrowserCellsTitleAttributesKey];
What I can't figure out is what is the magic key for setting the
color of the title and subtitle. I've tried: foregroundColor,
ForegroundColor, color, Color, titleColor, TitleColor and probably a
few others. I've also tried using both CIColor (as shown above) and
NSColor. As far as I can tell from a search of the documentation the
actual keys are not documented.
Any help would be greatly appreciated.
Thanks very much.
Thaddeus O. Cooper
(email@hidden)
_______________________________________________
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
_______________________________________________
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