PDA

View Full Version : How to set text right aligned in NSTextField while using setAttributedStringValue




Monaj
Oct 27, 2009, 01:51 AM
hi all,

I am caught in a small problem.

When I am assigning normal values to a text field using setStringValue and making the text right aligned through IB, it works fine! But when I try to assign it NSAttributedString using setAttributedStringValue: the text appears in correct color and font but does not appear to be right aligned, it always appear to be left aligned irrespective of any setting in IB.:eek:
I have tried to do it via code using setAllignment:NSRightTextAllignment and event tried to look for suitable methods in class references but cannot find one.

Can anyone suggest me the appropriate method:confused:

Thanks in advance,

Manoj



kainjow
Oct 27, 2009, 11:39 AM
You could try providing a custom NSParagraphStyle for the attributed string, and use its setAlignment: method instead.

Monaj
Oct 27, 2009, 11:20 PM
Thanks a ton, Kainjow! :)