【问题标题】:Stackview different depending on device it runs on swiftStackview 因在 swift 上运行的设备而异
【发布时间】:2016-11-03 19:36:42
【问题描述】:

我在 stackview 中有 4 个按钮。按钮没有任何约束。堆栈视图固定在左侧、右侧和底部。不需要更多约束的警告。问题是当我在 5 上运行它时它看起来不错,但在任何更大的设备上它都不正确。我有以下代码使用这些按钮。

这使得白线

extension CGRect {
    init(_ x:CGFloat, _ y:CGFloat, _ w:CGFloat, _ h:CGFloat) {
        self.init(x:x, y:y, width:w, height:h)
    }
}

extension UIView {
    func addTopBorderWithColor(color: UIColor, width: CGFloat) {
        let border = CALayer()
        border.backgroundColor = color.cgColor
        border.frame = CGRect(0, 0, self.frame.size.width, width)
        self.layer.addSublayer(border)
    }
}

然后我从笔尖醒来,开始画它们。

class DigitButtomFrame: UIButton {
    override func awakeFromNib() {
        addTopBorderWithColor(color: .white, width: 1.0)
    }
}

【问题讨论】:

    标签: ios uibutton swift3 uistackview xcode8.1


    【解决方案1】:

    我已经确定要运行模拟器的任何设备,我必须在视图中将其选择为:主故事板上的 iPhone 部分。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-09-14
      • 2013-12-15
      • 2021-07-12
      • 1970-01-01
      • 2014-07-26
      • 2018-10-28
      • 2016-10-15
      相关资源
      最近更新 更多