<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 文本对齐

        AutoLayout + RTL + UILabel text alignment(AutoLayout + RTL + UILabel 文本对齐)
            <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 文本对齐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  iOS AutoLayout - get frame size width(iOS AutoLayout - 获取帧大小宽度)
                  Auto layout constraints issue on iOS7 in UITableViewCell(UITableViewCell中iOS7上的自动布局约束问题)
                  How to resize superview to fit all subviews with autolayout?(如何调整超级视图的大小以适应所有具有自动布局的子视图?)
                  Springs in Auto Layout: Distribute views evenly, with constraints, in Xcode 5(自动布局中的弹簧:在 Xcode 5 中使用约束均匀分布视图)
                  reloadData() of UITableView with Dynamic cell heights causes jumpy scrolling(具有动态单元格高度的 UITableView 的 reloadData() 导致跳跃滚动)
                  What is NSLayoutConstraint quot;UIView-Encapsulated-Layout-Heightquot; and how should I go about forcing it to recalculate cleanly?(什么是 NSLayoutConstraint“UIView-Encapsulated-Layout-Height?我应该如何强制它干净地重新计算?) - IT屋-程序员

                  • <small id='JNDFa'></small><noframes id='JNDFa'>

                  • <legend id='JNDFa'><style id='JNDFa'><dir id='JNDFa'><q id='JNDFa'></q></dir></style></legend>

                      <tbody id='JNDFa'></tbody>

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