Reputation: 1
I want to align the top position of the items in the red box of picture 2 as shown in picture 1.
When an item is selected, the image is automatically aligned. Is there a way to float the padding from the tab bar based on the top of the image?
Upvotes: 0
Views: 1231
Reputation: 31
You can move the position of Image by using this code. If you used title with that image so you should use this title in place of nil.
extension UITabBarController {
override open func viewDidLayoutSubviews() {
let items = tabBar.items
for item in items!
{
if item.title == nil {
item.imageInsets = UIEdgeInsets(top: -20, left: 0, bottom: 10, right: 0)
}
}
}
}
Upvotes: 3