0

我在堆栈视图中有 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)
    }
}

iphone 5 iPhone 7s

4

1 回答 1

0

I have figured out whatever device I want to run simulator I have to have it selected in the view as: iPhone sections on main storyboard.

于 2016-11-04T17:27:31.110 回答