leading or trailing horizontal alignment before iOS 11

Prabhav picture Prabhav · Nov 23, 2017 · Viewed 9k times · Source

Warning: leading or trailing horizontal alignment before iOS 11

I am getting above warning during compilation on Xcode 9.1 on one of the scenes in a storyboard file. There are other storyboards (with deployment target iOS 10.0) and yet the warning is shown to this specific scene on a specific Storyboard file.

The warning gets suppressed if I change deployment target to iOS 11.0 on the scene where warning is shown but I don't want to do that.

Has anyone come across this case?

Answer

Grzegorz Krukowski picture Grzegorz Krukowski · Dec 18, 2017

For me the problem was in using trailing leading alignment on UIButton itself.

Safe area seems to be completely fine to use - it's backward compatible and it translates into proper super view margins.

But this feature is iOS 11 only, so use standard left / right alignment instead if you are targeting lower iOS versions.

Easiest way to find out which view is causing the problem is to search for contentHorizontalAlignment="leading" or contentHorizontalAlignment="trailing" in source code for .xib

enter image description here