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

  • <tfoot id='Uk75F'></tfoot>

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

          <bdo id='Uk75F'></bdo><ul id='Uk75F'></ul>
      2. <small id='Uk75F'></small><noframes id='Uk75F'>

        iPhone UIButton - 图像位置

        时间:2023-07-09

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

                <tfoot id='jEAjE'></tfoot>
              1. <small id='jEAjE'></small><noframes id='jEAjE'>

                  <legend id='jEAjE'><style id='jEAjE'><dir id='jEAjE'><q id='jEAjE'></q></dir></style></legend>
                    <tbody id='jEAjE'></tbody>
                • 本文介绍了iPhone UIButton - 图像位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个 UIButton 带有文本探索应用程序"和 UIImage (>)在 Interface Builder 中它看起来像:

                  I have a UIButton with text "Explore the app" and UIImage (>) In Interface Builder it looks like:

                  [ (>) Explore the app ]
                  

                  但我需要将这个 UIImage 放在文本之后:

                  But I need to place this UIImage AFTER the text:

                  [ Explore the app (>) ]
                  

                  如何将 UIImage 向右移动?

                  推荐答案

                  这是我自己的做法,(大约 10 年后)

                  1. UIButton 的子类(按钮,因为我们生活在 Swift 时代)
                  2. 将图像和标签放入堆栈视图.

                  class CustomButton: Button {
                  
                      var didLayout: Bool = false // The code must be called only once
                  
                      override func layoutSubviews() {
                          super.layoutSubviews()
                          if !didLayout, let imageView = imageView, let titleLabel = titleLabel {
                              didLayout = true
                              let stack = UIStackView(arrangedSubviews: [titleLabel, imageView])
                              addSubview(stack)
                              stack.edgesToSuperview() // I use TinyConstraints library. You could handle the constraints directly
                              stack.axis = .horizontal
                          }
                      }
                  }
                  

                  这篇关于iPhone UIButton - 图像位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:UIButton 删除所有目标动作 下一篇:iPhone 上的最小合理按钮大小

                  相关文章

                  <legend id='2TLBy'><style id='2TLBy'><dir id='2TLBy'><q id='2TLBy'></q></dir></style></legend><tfoot id='2TLBy'></tfoot>

                    1. <small id='2TLBy'></small><noframes id='2TLBy'>

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