我正在查看SnapKit文档:http://snapkit.io/docs/
如果转到“使用”部分,它有以下示例代码:
let box = UIView()
superview.addSubview(box)
box.snp_makeConstraints { (make) -> Void in
make.top.equalTo(superview).offset(20)
make.left.equalTo(superview).offset(20)
make.bottom.equalTo(superview).offset(-20)
make.right.equalTo(superview).offset(-20)
}使一个盒子被限制到它的superview的边缘与20的填充。
我试着在我自己的项目中这样做:
thankYouMessage.snp_makeConstraints { (make) -> Void in
make.right.left.top.equalTo(superview)
make.height.equalTo(self.view.frame.height * 0.2)
}然而,在Xcode中,它说“未解决的使用标识符superview”。
有什么问题吗?
发布于 2017-01-10 13:31:29
thankYouMessage.snp.makeConstraints { make in
make.right.left.top.equalToSuperview()
make.height.equalToSuperview().multipliedBy(0.2) // or .dividedBy(5)
}https://stackoverflow.com/questions/37556117
复制相似问题