gpt4 book ai didi

ios - "superview"无法识别

转载 作者:行者123 更新时间:2023-11-29 00:56:43 26 4
gpt4 key购买 nike

我正在查看 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)
}

制作一个盒子,用 20pts 的填充将其限制在其父 View 的边缘。

我尝试在自己的项目中这样做:

thankYouMessage.snp_makeConstraints { (make) -> Void in
make.right.left.top.equalTo(superview)
make.height.equalTo(self.view.frame.height * 0.2)
}

但是在 Xcode 中它显示“未解决标识符 super View 的使用”。

问题是什么?

最佳答案

thankYouMessage.snp.makeConstraints { make in
make.right.left.top.equalToSuperview()
make.height.equalToSuperview().multipliedBy(0.2) // or .dividedBy(5)
}

关于ios - "superview"无法识别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37556117/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com