Hidden
Hidden

Reputation: 1

swift 4: Setting button's constrains to safe area while inside a view

I have a return button that is inside a view on the top left corner, and that view is anchored to the top of the safe area.

What I'm trying to set is the button's top and leading constraint to the top and the leading of the safe area, but since the button is inside a view I guess the safe area is not visible to it?

So what can I do to set the top constraint of the button to the top of the safe area rather than the superview that the button is inside? fix the button issue without taking the button outside of the view and make it overlap with the view and sitting its z-index above it.

superview constraints

button constraints

the arrow-shaped button on the top-left corner, and the view colored with navy blue.

iPhone 8 simulator

iPhone X simulator

Upvotes: -1

Views: 704

Answers (1)

Shehata Gamal
Shehata Gamal

Reputation: 100541

From your images it seems like that you don't set the top constraint of the top view to top safeAreaLayoutGuide instead you set it to superView here

enter image description here

, also you can't set the top of the button to safeArea , as it's only appears for direct subviews of thw main vc's view not to nested subviews

Upvotes: 0

Related Questions