How to set text right aligned in NSTextField while using setAttributedStringValue

Discussion in 'Mac Programming' started by Monaj, Oct 26, 2009.

  1. macrumors regular

    Joined:
    May 24, 2009
    #1
    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
     
  2. Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #2
    You could try providing a custom NSParagraphStyle for the attributed string, and use its setAlignment: method instead.
     
  3. thread starter macrumors regular

    Joined:
    May 24, 2009
    #3
    Thanks a ton, Kainjow! :)
     

Share This Page