2

I am using NSLayoutAnchor's constraintEqualToSystemSpacingAfter for building my layout.

NSLayoutConstraint.activate([
    customView.leadingAnchor.constraintEqualToSystemSpacingAfter(safeAreaLayoutGuide.leadingAnchor, multiplier: 1)
])

It actually works, but it throws a warning in the console after I activate the constraints:

Aligning the right edge of a [custom view] with the right edge of a [second custom view] is not recommended. Use an explicit constant for your constraint to override this.

How can I make this warning disappear?

Tamás Sengel
  • 55,884
  • 29
  • 169
  • 223

1 Answers1

3

Use NSLayoutAnchor.constraint(equalTo:constant:) instead of that method.

NSLayoutConstraint.activate([
    customView.leadingAnchor.constraint(equalTo: safeAreaLayoutGuide.leadingAnchor, constant: 0)
])
Tamás Sengel
  • 55,884
  • 29
  • 169
  • 223