I want to make a UIView rectangular with SnapKit in Swift, like this
lazy var customView: UIView = {
let view = UIView(frame: CGRect())
self.addSubview(view)
view.snp.makeConstraints({ (make) in
make.left.top.bottom.equalToSuperview().inset(self.inset)
make.width.equalTo(make.height) // Error in this line
})
return view
}()
You have to use view.snp.height
instead of make.height
:
lazy var customView: UIView = {
let view = UIView(frame: CGRect())
self.addSubview(view)
view.snp.makeConstraints({ (make) in
make.left.top.bottom.equalToSuperview().inset(self.inset)
make.width.equalTo(view.snp.height) // <---
})
return view
}()