Snapkit: Constrain multiple to margins
One nice way to do this is to use UIView.layoutMarginsGuide
:
childView.snp.makeConstraints { make in
make.top.leading.bottom.equalTo(parentView.layoutMarginsGuide)
make.trailing.equalTo(otherView.snp.leading).offset(-8.0)
}
did you try something like this?
subView.snp.makeConstraints { make in
make.edges.equalTo(view.snp.margins)
}
Edit after comment:
When you only want to constrain certain edges to the superview margin, you can do something like this.
subView.snp.makeConstraints { make in
make.top.leading.equalTo(view).inset(view.layoutMargins)
}
or
subView.snp.makeConstraints { make in
make.top.leading.equalTo(view.layoutMarginsGuide)
or
subView.snp.makeConstraints { make in
make.top.leading.equalTo(view.safeAreaLayoutGuide)