【发布时间】:2016-09-18 13:52:54
【问题描述】:
我更新了 Xcode 8 和 SnapKit 3.0 来测试自动布局。在我更新到 SnapKit 3.0 之前,我可以在调用 layoutIfNeeded 后得到正确的帧。但是我现在在 SnapKit 3.0 下得到了 frame.origin.x 和 .y 两个负值。
示例:
let signUpView = UIView()
view.addSubview(signUpView)
signUpView.snp.makeConstraints { (make) -> Void in
make.leading.equalTo(50)
make.trailing.equalTo(-50)
make.top.equalTo(topView.snp.bottom)
make.height.equalTo(50)
}
// here frame is: {0,0,0,0}
signUpView.layoutIfNeeded()
// here frame is:
(-137.5, -25.0, 275.0, 50.0)
▿ origin : (-137.5, -25.0)
- x : -137.5
- y : -25.0
▿ size : (275.0, 50.0)
- width : 275.0
- height : 50.0
【问题讨论】: