【问题标题】:Programmatically Set Spacing on Stackview以编程方式在 Stackview 上设置间距
【发布时间】:2016-11-19 22:28:47
【问题描述】:

正如标题所说,我已经四处寻找,但没有运气。是否可以将堆栈视图连接到 .swift 文件,然后以编程方式调整间距?谢谢!

【问题讨论】:

    标签: ios swift uistackview


    【解决方案1】:
    let stackView = UIStackView()
    stackView.spacing = 10.0      // or whatever you like
    

    【讨论】:

      【解决方案2】:

      如果您有自定义 UIStackView

      class YourCustomSublcass {
        //MARK: Initialization of the stackView
        override init(frame: CGRect) {
          super.init(frame: frame)
          self.spacing = 8.0
        }
      
        required init(coder :NSCoder){
          super.init(coder: coder)
          self.spacing = 8.0
        }
      }
      

      【讨论】:

        猜你喜欢
        • 2016-12-23
        • 1970-01-01
        • 1970-01-01
        • 2011-01-29
        • 2019-10-19
        • 2023-04-01
        • 1970-01-01
        • 2014-11-26
        • 1970-01-01
        相关资源
        最近更新 更多