UITabBar selectionIndicatorImage height on iPhone X

I use selectionIndicatorImagefor UITabBar, which is 49 points higher, for example:UITabBar.appearance().selectionIndicatorImage = UIImage(named: "bg-tab-selected")

Works well on all devices: enter image description here

Except for the iPhone X:

enter image description here

I tried to set the images to be vertically cut only in the asset catalog, but this does not seem to have the desired effect. For some reason, does it also stretch horizontally? And actually there are a few extras.

enter image description here

Any ideas how I can fix this?

+6
source share
2 answers

I had the same problem. I “fixed” it by subtracting the height by 1 pixel, so 48 pixels for the height of the selected image. This seems to be an iPhone X error.

+22

1 tabBarIndicatorImage Insets, , .

tabBar.selectionIndicatorImage?.resizableImage(withCapInsets: UIEdgeInsets.init(top: 1, left: 0, bottom: 0, right: 0))

-1

All Articles