Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITabBarItem and icon size

I am using UITabBarItem. If i set image, its not correctly displayed. Image is "zoomed", so I can see only top part of it. Image size is 60x60px.

I am setting image from xcodes XIB editor -> BarItem -> Image

Whats wrong with it ? According to Apple Doc, image should be 60x60 for Retina and even bigger images should be auto-scaled to fit viewing area.

like image 793
Martin Perry Avatar asked Jan 31 '26 09:01

Martin Perry


2 Answers

When you are supplying a retina image you should name it with [name]@2x~iphone.png or [name]@2x~ipad.png. Then, in the IB you should put the name of the file without the whole suffix, so just [name] instead of [name]@2x~iphone.png. The image won't show up in the IB, but should be ok in the live app.

like image 118
Maciej Trybiło Avatar answered Feb 01 '26 21:02

Maciej Trybiło


First, you have to make two icons, one of 30x30, and a second one 60x60 with "@2x" appended at the end of your filename.

Then bind the 30x30 icon to your UITabBarItem in XIB editor. Apple should select automatically the appropriate picture to display depending on the device it's running on.

like image 26
Bigood Avatar answered Feb 01 '26 22:02

Bigood



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!