<i id='WyX4A'><tr id='WyX4A'><dt id='WyX4A'><q id='WyX4A'><span id='WyX4A'><b id='WyX4A'><form id='WyX4A'><ins id='WyX4A'></ins><ul id='WyX4A'></ul><sub id='WyX4A'></sub></form><legend id='WyX4A'></legend><bdo id='WyX4A'><pre id='WyX4A'><center id='WyX4A'></center></pre></bdo></b><th id='WyX4A'></th></span></q></dt></tr></i><div id='WyX4A'><tfoot id='WyX4A'></tfoot><dl id='WyX4A'><fieldset id='WyX4A'></fieldset></dl></div>

    1. <tfoot id='WyX4A'></tfoot>
        <bdo id='WyX4A'></bdo><ul id='WyX4A'></ul>

      <small id='WyX4A'></small><noframes id='WyX4A'>

      <legend id='WyX4A'><style id='WyX4A'><dir id='WyX4A'><q id='WyX4A'></q></dir></style></legend>
      1. AutoLayout + RTL + UILabel 文本对齐

        时间:2023-09-11
            <bdo id='1LZco'></bdo><ul id='1LZco'></ul>
            <legend id='1LZco'><style id='1LZco'><dir id='1LZco'><q id='1LZco'></q></dir></style></legend>
          • <small id='1LZco'></small><noframes id='1LZco'>

              <tbody id='1LZco'></tbody>
              • <i id='1LZco'><tr id='1LZco'><dt id='1LZco'><q id='1LZco'><span id='1LZco'><b id='1LZco'><form id='1LZco'><ins id='1LZco'></ins><ul id='1LZco'></ul><sub id='1LZco'></sub></form><legend id='1LZco'></legend><bdo id='1LZco'><pre id='1LZco'><center id='1LZco'></center></pre></bdo></b><th id='1LZco'></th></span></q></dt></tr></i><div id='1LZco'><tfoot id='1LZco'></tfoot><dl id='1LZco'><fieldset id='1LZco'></fieldset></dl></div>
                <tfoot id='1LZco'></tfoot>

                  本文介绍了AutoLayout + RTL + UILabel 文本对齐的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我终于开始与自动布局搏斗,但似乎无法弄清楚如何获得从右到左 (RTL) 支持以按照我期望/想要的方式工作...

                  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...

                  我在 Interface Builder 中设计了如下所示的视图:

                  I have designed the view in Interface Builder as shown:

                  使用英语时生成的应用程序按预期运行:

                  With the resulting app running as expected when using English:

                  但是,当切换到 RTL 语言(在这种情况下为阿拉伯语)时,整个视图会翻转(这很棒),但 UILabel 的文本仍然是左对齐的.我希望它正确对齐以使其与 UIImageView 保持一致.

                  However when switching to an RTL language (Arabic in this case), the entire view flips (which is great) but the UILabel's text is still left aligned. I'd expect it to be right aligned to keep it up against the UIImageView.

                  显然我遗漏了一些东西和/或这不在自动布局中.

                  Clearly I'm missing something and/or this isn't covered by Auto Layout.

                  我应该在使用 RTL 语言时手动设置 textAlignment 吗?

                  Am I supposed to set the textAlignment manually when using an RTL language?

                  推荐答案

                  你想要 NSTextAlignmentNatural.这会从加载的应用程序语言(not 来自脚本)推断文本对齐方式.

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

                  对于 iOS 9 及更高版本(使用 Xcode 7),您可以在情节提要中进行设置(选择 --- 对齐选项).如果您需要针对早期版本,则需要创建标签的出口并在 awakeFromNib 中设置对齐方式.

                  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];
                  }
                  

                  这篇关于AutoLayout + RTL + UILabel 文本对齐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:是否可以使用自动布局获得动态表格视图部分标题高度? 下一篇:UIStackView 分布填充均等

                  相关文章

                1. <small id='JNDFa'></small><noframes id='JNDFa'>

                2. <legend id='JNDFa'><style id='JNDFa'><dir id='JNDFa'><q id='JNDFa'></q></dir></style></legend>

                    <tfoot id='JNDFa'></tfoot>
                    • <bdo id='JNDFa'></bdo><ul id='JNDFa'></ul>
                    <i id='JNDFa'><tr id='JNDFa'><dt id='JNDFa'><q id='JNDFa'><span id='JNDFa'><b id='JNDFa'><form id='JNDFa'><ins id='JNDFa'></ins><ul id='JNDFa'></ul><sub id='JNDFa'></sub></form><legend id='JNDFa'></legend><bdo id='JNDFa'><pre id='JNDFa'><center id='JNDFa'></center></pre></bdo></b><th id='JNDFa'></th></span></q></dt></tr></i><div id='JNDFa'><tfoot id='JNDFa'></tfoot><dl id='JNDFa'><fieldset id='JNDFa'></fieldset></dl></div>