This works but it is an overkill for a simple and common thing.
I came across topLayoutGuideCartography and bottomLayoutGuideCartography while looking for a random solution. Assigning them directly to the searchBar.Top does the magic without overriding viewDidLayoutSubviews or updating any constraints in a later time.
If this is their designated use case. They should be mentioned in the README. This is a very common layout problem and SO is full of them. If needed I can open a PR for that.
If this is just a coincidence, I would like to know the right answer.
I am not sure if I miss something here or it is not clear in cartography. Correct me if I am wrong.
This is a common case with a navigation bar and any view/view controller in every ios app.
Any layout using
top
here will cause problems since if you align any item'stop
withsuperView.top
, it will go undernavBar
.Using
topLayoutGuide
is an option here but the way we update is kind of an overkill.build the constraints
and update the desired constraint in
viewDidLayoutSubviews
This works but it is an overkill for a simple and common thing.
I came across
topLayoutGuideCartography
andbottomLayoutGuideCartography
while looking for a random solution. Assigning them directly to thesearchBar.Top
does the magic without overridingviewDidLayoutSubviews
or updating any constraints in a later time.If this is their designated use case. They should be mentioned in the README. This is a very common layout problem and SO is full of them. If needed I can open a PR for that.
If this is just a coincidence, I would like to know the right answer.
Thanks !