-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is it possible to get the NSLayoutConstraint when using SnapKit? #133
Comments
@NicholasTD07 you probably don't want to store the NSLayoutConstraint since SnapKit will uninstall and re-install these (sometimes creating new ones) as necessary. Instead you want to store the SnapKit
You can then find methods on that constraint! |
@robertjpayne Oh, right. Sorry I have only been using SnapKit for a few days so I keep forgetting SnapKit manage(install/re-install) But, in this case, when I do need to hold onto a |
@NicholasTD07 what's the reasoning for needing the NSLayoutConstraint directly? If you look at the methods available on Constraint here https://github.com/SnapKit/SnapKit/blob/develop/Source/Constraint.swift it should be everything above and beyond you would need? |
You can mix regular constraints into SnapKit too, no conflict so long as the constraints are still satisfiable. SnapKit will never touch non SnapKit constraints with the exception of turning off automatic autoresizing flag constraints. |
@robertjpayne If you look into AMScrollingNavbar's README there's a section where you can use it with a By the way, SnapKit is so cool! And the code is so clean. Good job. 👍 👍 |
@NicholasTD07 ah yea, basically SnapKit automagically removes and manages any NSLayoutConstraint's it creates so it's not easy to try and get them directly. You're best creating that one specifically via the native apis! |
@robertjpayne Cool. Thank you for helping me understand the internal mechanism of SnapKit and find the solution(native API). |
No worries! |
I know I can get
SnapKit.Constraint
from SnapKit by doingtopConstraint = make.top.equalTo(superview).offset(padding.top).constraint
.However, is there a way to get the underlining
NSLayoutConstraint
? I need to get the constraint to work with AMScrollingNavbar.For example, let's say I have
Is it possible to get the
NSLayoutConstraint
for the top constraint of thecontainer
invc
?PS.
SnapKit is awesome! It makes my life with AutoLayout so much easier. ;D
Thanks for the great work.
The text was updated successfully, but these errors were encountered: