I have a question about aligning content using autolayout.
I have a large navigation bar and one UIView right below the navigation bar. I want to set the UIView's leading anchor to the same leading anchor as the navigation bar. Currently, my code is something below and the view's leading anchor is not the same as the navigation bar's leading. (yes, because I'm using layoutMarginsGuide so that's why.)
NSLayoutConstraint.activate([
myView.topAnchor.constraint(equalTo: self.safeAreaLayoutGuide.topAnchor),
myView.bottomAnchor.constraint(equalTo: self.safeAreaLayoutGuide.bottomAnchor),
myView.leadingAnchor.constraint(equalTo: self.layoutMarginsGuide.leadingAnchor),
myView.trailingAnchor.constraint(equalTo: self.layoutMarginsGuide.trailingAnchor),
myView.centerXAnchor.constraint(equalTo: self.centerXAnchor)
])
I used Figma and figured out the padding of large navigation bar (for iPhoneSE) was 16, so I can set the constraint for the myView's leading anchor as
myView.leadingAnchor.constraint(equalTo: self.view.leadingAnchor, constant: 16)
but I was wondering if there is a way to align without using a fixed constant value, 16?. I've looked up Safe Area Layout Guide and Layout Margins Guide, but I could not change the view as I wanted.