Skip to content

Instantly share code, notes, and snippets.

@Rm1210
Last active December 24, 2015 01:49
Show Gist options
  • Save Rm1210/6726329 to your computer and use it in GitHub Desktop.
Save Rm1210/6726329 to your computer and use it in GitHub Desktop.
Change IKImageBrowserView Title & Subtitle
// 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];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment