glyvox
glyvox

Reputation: 58099

Console warning when using NSLayoutAnchor.constraintEqualToSystemSpacingAfter

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?

Upvotes: 2

Views: 217

Answers (1)

glyvox
glyvox

Reputation: 58099

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

NSLayoutConstraint.activate([
    customView.leadingAnchor.constraint(equalTo: safeAreaLayoutGuide.leadingAnchor, constant: 0)
])

Upvotes: 3

Related Questions