iOS 11 iPhone X UINavigationbar background image too small

I had a problem in one of my apps, that the background image I set, was too small for the new iPhone X.
So I tried a few things, but nothing worked. For example you could add a taller @3x background image, but then it would be clipped on an iPhone 8 Plus for example.

Finally I found a working solution for swift 3.2. (It should also work in swift 4)

Code:

On the left side is a iPhone 8 Plus simulator and on the right side is the iPhone X simulator.

Before:
iPhone X uinavigationbar background image too small
After:
iPhone X uinavigationbar background image scalled
As you can see now the background image scales properly.

One Response to “iOS 11 iPhone X UINavigationbar background image too small”

  1. James

    Thank you exactly what I was looking for!
    I searched for „navigationbar background image fill“ and „UINavigationBar background image with scaleAspectFill-like behavior“, but all the solutions didn’t work. Except for this one!

    Antworten

Leave a Reply