Re: Centering an NSAttributedString in a line in a view
Re: Centering an NSAttributedString in a line in a view
- Subject: Re: Centering an NSAttributedString in a line in a view
- From: email@hidden
- Date: Wed, 19 Jul 2006 19:50:34 +0200 (CEST)
- Importance: Normal
>Put an NSLog on your "parsty" as soon as it is set (i.e. before you change
>it, as it comes from super). I think you'll see right away that you've made
>an unwarranted and incorrect assumption.
I don't quite follow you ? Before sending my original post, I analized this
problem with the debugger ( I redid that after your last post, to be sure)
and it seems that everything goes as planned during the compilation phase.
To quote the debugger :
(gdb) po parsty (*just before the line [parsty setAlignment:
NSCenterTextAlignment] gets called*)
Alignment 4, LineSpacing 0, ParagraphSpacing 0, ParagraphSpacingBefore 0,
HeadIndent 0, TailIndent 0, FirstLineHeadIndent 0, LineHeight 0/0,
LineHeightMultiple 0, LineBreakMode 0, Tabs (288C, 576R),
DefaultTabInterval 0, Blocks (null), Lists (null), BaseWritingDirection
-1, HyphenationFactor 0, TighteningFactor 0.05, HeaderLevel 0
(gdb) po parsty (* just after that line has been executed *)
Alignment 2, LineSpacing 0, ParagraphSpacing 0, ParagraphSpacingBefore 0,
HeadIndent 0, TailIndent 0, FirstLineHeadIndent 0, LineHeight 0/0,
LineHeightMultiple 0, LineBreakMode 0, Tabs (288C, 576R),
DefaultTabInterval 0, Blocks (null), Lists (null), BaseWritingDirection
-1, HyphenationFactor 0, TighteningFactor 0.05, HeaderLevel 0
All I understand here is that the Alignement parameter has been
modified in parsty, exactly as I wanted.
What am I supposed to ``see right away" here ? Is there some parameter
that should be nonzero ?
Ewan
> On or about 7/19/06 2:14 AM, thus spake "email@hidden"
>>
>> -(NSAttributedString*) pageFooter
>> {
>> NSAttributedString* oldFooter;
>> NSMutableAttributedString* newFooter;
>> unsigned footerLength;
>> NSRange range;
>> NSDictionary* attributes;
>> NSMutableParagraphStyle* parsty;
>>
>> oldFooter=[super pageFooter];
>> footerLength=[oldFooter length];
>> range.location=0;
>> range.length=footerLength;
>> attributes=[oldFooter
>> attributesAtIndex: 0
>> longestEffectiveRange: NULL
>> inRange: range];
>> parsty=[attributes objectForKey : NSParagraphStyleAttributeName];
>> [parsty setAlignment: NSCenterTextAlignment];
>> newFooter=
>> [[NSMutableAttributedString alloc]
>> initWithAttributedString: oldFooter];
>> [newFooter
>> addAttribute: NSParagraphStyleAttributeName
>> value: parsty
>> range: range];
>> return newFooter;
>> }
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden