简体   繁体   中英

UITabBar selectionIndicatorImage height on iPhone X

I'm using a selectionIndicatorImage for a UITabBar , which is 49 points high, like this: UITabBar.appearance().selectionIndicatorImage = UIImage(named: "bg-tab-selected")

Works just fine across all devices: 在此处输入图片说明

Except for the iPhone X:

在此处输入图片说明

I've tried setting the images to be vertically sliced only in the asset catalog, but that doesn't seem to have the desired effect. For some reason it also stretches horizontally? And there is a bit of padding on top.

在此处输入图片说明

Any ideas how I can fix this?

I had the same issue. I "fixed" it by subtracting the height by 1 pixel, so 48 pixels for the height of the selection image. It seems to be an iPhone X bug.

在 tabBar 的 selectionIndicatorImage Insets 的顶部或底部添加 1 个点似乎暂时“修复”了这个问题。

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM