"superview" 无法识别

"superview" not recognized

我正在查看 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 的填充创建一个限制在其父视图边缘的框。

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

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

但是在 Xcode 中显示 "unresolved use of identifier superview"。

问题是什么?

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