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.

Suchbegriffe:

https://www devno com/1242-ios-11-iphone-x-navigationbar-background-image-too-small/

Leave a Reply