• 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: NSMutableAttributeString, fonts and alignment
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSMutableAttributeString, fonts and alignment


  • Subject: Re: NSMutableAttributeString, fonts and alignment
  • From: Vince DeMarco <email@hidden>
  • Date: Wed, 19 Dec 2001 09:39:20 -0800

On Tuesday, December 18, 2001, at 08:36 pm, Simson Garfinkel wrote:
What's missing is some way of setting the strings alignment. That appears to
be set through the setAlignment:range: method.

Unfortunately, there appears to be no way to put an Alignment into a
dictionary. (It's not defined). So I have code that looks like this:

- (void)setColor:(NSColor *)aColor
{
[dict setObject:aColor forKey:NSForegroundColorAttributeName];
[text setAttributes:dict range:NSMakeRange(0,[text length])];
[text setAlignment:NSCenterTextAlignment range:NSMakeRange(0,[text
length])]; // bug in appkit
}

I think that this is pretty ugly. I'm sure that I can hard-code the correct
key for alignment, but I don't want to do that. I want to know what the
APPKIT_EXTERN is. Anybody know anything I don't?


Try this

{
NSMutableParagraphStyle *modifiedStyle;
NSTextTab *tabStop;

tabStop = [[NSTextTab alloc] initWithType:NSLeftTabStopType location:100.0];
modifiedStyle = [[NSMutableParagraphStyle alloc] init];
[modifiedStyle setTabStops:[NSArray arrayWithObject:tabStop]];

[[textView textStorage] addAttribute:NSParagraphStyleAttributeName value:modifiedStyle range:range];
[tabStop release];
[modifiedStyle release];
}


NSParagraphStyle has this method

- (void)setAlignment:(NSTextAlignment)alignment;


  • Follow-Ups:
    • Re: NSMutableAttributeString, fonts and alignment
      • From: "Simson Garfinkel" <email@hidden>
References: 
 >NSMutableAttributeString, fonts and alignment (From: "Simson Garfinkel" <email@hidden>)

  • Prev by Date: Re: How to display second window?
  • Next by Date: Re: Re(2): God, that's NOT THE WAY!!!! (was: Use -display INSTEAD of -setNeedsDisplay)
  • Previous by thread: Re: NSMutableAttributeString, fonts and alignment
  • Next by thread: Re: NSMutableAttributeString, fonts and alignment
  • Index(es):
    • Date
    • Thread