AutoLayout + RTL + UILabel text alignment

前端 未结 9 1066
面向向阳花
面向向阳花 2020-11-28 11:18

I\'m finally getting round to wrestling with Auto Layout and can\'t seem to figure out how to get right-to-left (RTL) support to work the way I\'d expect/want...

I h

9条回答
  •  爱一瞬间的悲伤
    2020-11-28 11:36

    You want NSTextAlignmentNatural. That infers the text alignment from the loaded application language (not from the script).

    For iOS 9 and later (using Xcode 7), you can set this in the storyboard (choose the --- alignment option). If you need to target earlier releases, you'll need to create an outlet to the label and set the alignment in awakeFromNib.

    - (void)awakeFromNib {
        [[self label] setTextAlignment:NSTextAlignmentNatural];
    }
    

提交回复
热议问题