iOS Autolayout constraint between non-siblings -


is there way define horizontal distance constraint between 2 views not siblings? tried add constraint first common superview constraint doesn't seem work.

the apple documentation says:

the constraint may reference view or subviews.

but i'm not sure if meant direct subviews or not.

rationale: have view want put different children , arrange them. of children should shown vibrancy effect. unfortunately, enabling or disabling vibrancy of view in ios done through placing in uivisualeffectview. in order have mixture of vibrant , non-vibrant views using 2 containers in top level view - 1 vibrant views , other rest. however, need arrange visual items relative each other constraints. since in different containers, need constraints work non-sibling views.

unless want support ~3% of users still on ios 7, don't manually add constraints any view:

when developing ios 8.0 or later, set constraint’s active property true instead. automatically adds constraint correct view.

create constraint referring both views, make sure they're in same view hierarchy, activate it.


Comments