UITabBar selectionIndicatorImage height on iPhone X

旧城冷巷雨未停 提交于 2019-11-29 13:50:18

问题


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?


回答1:


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.




回答2:


Adding 1 point to the top or bottom of your tabBar's selectionIndicatorImage Insets seems to "fix" this for now.

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



来源:https://stackoverflow.com/questions/46276728/uitabbar-selectionindicatorimage-height-on-iphone-x

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!