SnapKit / SnapKit

A Swift Autolayout DSL for iOS & OS X

Home Page:https://snapkit.github.io/SnapKit/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Difference between offset and inset?

gerchicov-vg opened this issue Β· comments

New Issue Checklist

🚫 If this template is not filled out your issue will be closed with no comment. 🚫

  • I have looked at the Documentation
  • I have read the F.A.Q.
  • I have filled out this issue template.

Issue Info

Info Value
Platform any
Platform Version any
SnapKit Version any
Integration Method any

Issue Description

I have the following code chunks:

someView.snp.makeConstraings {
    $0.top.equalToSuperview().offset(16)
}
someView.snp.makeConstraings {
    $0.top.equalToSuperview().inset(16)
}

Is there any difference (except of +/- signs before number)?

@gerchicov-vg offset's are always added to the constraint e.g. top + <offset> where as insets depend on the edge:

top + <inset>
bottom - <inset>
left + <inset>
right - <inset>
leading + <inset>
trailing - <inset>