ekkeee
ekkeee

Reputation: 147

Autolayout with Navigation Item

I'm trying to pin my UIImageView to the top via Autolayout and don't quite understand how to pin it to the Navigation Item itself.

It turns out to the view itself

How to write this line correctly?

imageView.topAnchor.constraint(equalTo: view.topAnchor, constant: 10) = true

Upvotes: 1

Views: 41

Answers (1)

boa_in_samoa
boa_in_samoa

Reputation: 607

The navigation bar is automatically added as a part of the safe area. You need to pin the top of your view to the safeAreaLayoutGuide like this:

imageView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor, constant: 10) = true

Same goes for the tab bar.

Upvotes: 2

Related Questions