0

I am looking at the SnapKit documentation: http://snapkit.io/docs/

If you go to the usage section it has the following example code:

 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)
}

to make a box that is constrained to its superview's edges with 20pts of padding.

I tried doing this in my own project:

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

However in Xcode it says "unresolved use of identifier superview".

What is the problem?

Foobar
  • 7,458
  • 16
  • 81
  • 161
  • `superview` is being used as a placeholder. They mean replace with the superview of a the view you are adding constraints to likely `self.view` if using in a view controller. – beyowulf May 31 '16 at 21:52

1 Answers1

1
thankYouMessage.snp.makeConstraints { make in
    make.right.left.top.equalToSuperview()
    make.height.equalToSuperview().multipliedBy(0.2) // or .dividedBy(5)
}
Matias Elorriaga
  • 8,880
  • 5
  • 40
  • 58