How to set text right aligned in NSTextField while using setAttributedStringValue

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

  1. Monaj
    Expand Collapse
    macrumors regular

    May 24, 2009
    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,

  2. kainjow
    Expand Collapse
    Moderator emeritus


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

    May 24, 2009

Share This Page