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

      <bdo id='dZ9ce'></bdo><ul id='dZ9ce'></ul>

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

        <tfoot id='dZ9ce'></tfoot>

      1. 即使有足够的空间可用于单词,UILabel 自动换行功能也会留下空间

        UILabel word wrap feature leaving space even when sufficient space available for the word(即使有足够的空间可用于单词,UILabel 自动换行功能也会留下空间)
            <tbody id='xKkTX'></tbody>

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

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

                  <tfoot id='xKkTX'></tfoot>
                  本文介绍了即使有足够的空间可用于单词,UILabel 自动换行功能也会留下空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  这个问题甚至出现在故事板中.

                  The problem coming even in storyboard.

                  UILabel 具有以下属性:

                  • numberOfLines = 0
                  • lineBreakMode = .byWordWrapping
                  • 约束:领先 &落后26分到superview;垂直居中.
                  • 自定义字体:中等 17 磅.

                  如您所见,第四个单词无法放入第一行,因此会出现布局错误的问题.如果我删除最后一个单词,则句子完全适合一行或说出第四个单词.如果在它之后添加一个单词会将它们都移动到下一行,这会留下很多空间.它应该尝试在一行中尽可能不中断或连字符来适应单词.但是很明显,即使单词可以容纳,也会产生空白.

                  您可以在新项目中重新创建它并观察问题.

                  You can recreate this in a new project and observe the issue.

                  推荐答案

                  你可能想试试这个...

                  You may want to give this a try...

                  子类 UITextView,禁用滚动、编辑和选择...将 textContainerInset = UIEdgeInsets.zerotextContainer.lineFragmentPadding = 0 设置为零.

                  Subclass UITextView, disable scrolling, editing and selecting... set the textContainerInset = UIEdgeInsets.zero and textContainer.lineFragmentPadding = 0 to Zero.

                  结果:

                  代码(@IBDesignable 所以我们可以在 IB/Storyboard 中看到它):

                  Code (@IBDesignable so we can see it in IB / Storyboard):

                  @IBDesignable
                  class TextViewLabel: UITextView {
                  
                      override init(frame: CGRect, textContainer: NSTextContainer?) {
                          super.init(frame: frame, textContainer: textContainer)
                          commonInit()
                      }
                  
                      required init?(coder aDecoder: NSCoder) {
                          super.init(coder: aDecoder)
                          commonInit()
                      }
                  
                      func commonInit() -> Void {
                          isScrollEnabled = false
                          isEditable = false
                          isSelectable = false
                          textContainerInset = UIEdgeInsets.zero
                          textContainer.lineFragmentPadding = 0
                      }
                  
                  }
                  

                  这篇关于即使有足够的空间可用于单词,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屋-程序员

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

                    <legend id='ja0Do'><style id='ja0Do'><dir id='ja0Do'><q id='ja0Do'></q></dir></style></legend>
                    <tfoot id='ja0Do'></tfoot>

                      <bdo id='ja0Do'></bdo><ul id='ja0Do'></ul>

                            <tbody id='ja0Do'></tbody>
                        1. <small id='ja0Do'></small><noframes id='ja0Do'>