How to correctly adjust the image height in a Uitabbaritem?

Asked

Viewed 54 times

1

I set up two images for one tabBarItem. As I couldn’t 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 the UITabBar:

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

Worked perfectly!

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

Normal state:

inserir a descrição da imagem aqui

After a few clicks in a row on the button:

inserir a descrição da imagem aqui

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

1 answer

0

I did some tests and noticed that it was a configuration problem.

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

WRONG:

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

CERTAIN

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

Therefore this method serves the purpose of adjusting the image in the tabBarItem.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.