• 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
Re: Setting text color in a NSFormCell
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Setting text color in a NSFormCell


  • Subject: Re: Setting text color in a NSFormCell
  • From: Michael Babin <email@hidden>
  • Date: Tue, 23 Oct 2007 08:09:08 -0500


On Oct 22, 2007, at 6:35 PM, R.L. Grigg wrote:

Hi Nick,
I was able to get setAttributedStringValue working, using an attributes dictionary. But I'm having difficulty getting the string centered in the cell:


NSDictionary *textDict=[NSDictionary dictionaryWithObjectsAndKeys:
[NSFont boldSystemFontOfSize: 10],NSFontAttributeName,
[NSColor redColor],NSForegroundColorAttributeName,nil];
NSAttributedString *attrStr=[[[NSAttributedString alloc]
initWithString:descrip
attributes:textDict] autorelease];
[fcell setAlignment:NSCenterTextAlignment];
[fcell setAttributedStringValue:attrStr];


This displays the text (from NSString var 'descrip') in bold red, but its left justified. Maybe I need to set NSCenterTextAlignment somehow in textDict also, but I don't see how to do that...?

Try using a paragraph style, as in:

NSMutableParagraphStyle *paragraphStyle = [[[NSMutableParagraphStyle alloc] init] autorelease];
[paragraphStyle setAlignment: NSCenterTextAlignment];


NSDictionary *textDict=[NSDictionary dictionaryWithObjectsAndKeys:
[NSFont boldSystemFontOfSize: 10],NSFontAttributeName,
[NSColor redColor],NSForegroundColorAttributeName,
paragraphStyle, NSParagraphStyleAttributeName,
nil];
NSAttributedString *attrStr=[[[NSAttributedString alloc]
initWithString:descrip
attributes:textDict] autorelease];
[fcell setAttributedStringValue:attrStr];


- Mike

_______________________________________________

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: Setting text color in a NSFormCell
      • From: "R.L. Grigg" <email@hidden>
References: 
 >Setting text color in a NSFormCell (From: "R.L. Grigg" <email@hidden>)
 >Re: Setting text color in a NSFormCell (From: Nick Zitzmann <email@hidden>)
 >Re: Setting text color in a NSFormCell (From: "R.L. Grigg" <email@hidden>)

  • Prev by Date: Re: Drawing Text in spiral shape
  • Next by Date: Re: nodesForXPath and namespace issue
  • Previous by thread: Re: Setting text color in a NSFormCell
  • Next by thread: Re: Setting text color in a NSFormCell
  • Index(es):
    • Date
    • Thread