How to correctly adjust the height of the image in a UITabBarItem?

1

I set up two images to a tabBarItem . Since I did not find a way to change the center of the image, I used the following method to make the image effect go up a few pixels, above UITabBar :

self.navigationController.tabBarItem.imageInsets = UIEdgeInsetsMake(4, 0, -5, 0);

It worked perfectly!

But during use, when the button is clicked several times in a row, the image is stretched.

Normal status:

Afterafewclicksonthebutton:

How to correctly adjust the height of the image, or change the height of the UITabBarItem itself, without experiencing this problem?

    
asked by anonymous 05.05.2015 / 03:46

1 answer

0

I did some testing and noticed it was a configuration problem.

The correct value to be sent to the method must be the same:

WRONG:

self.navigationController.tabBarItem.imageInsets = UIEdgeInsetsMake(4, 0, -5, 0);

RIGHT

self.navigationController.tabBarItem.imageInsets = UIEdgeInsetsMake(5, 0, -5, 0);

So this method serves the purpose of adjusting the image on the tabBarItem.

    
06.05.2015 / 01:00