iOS: How to set the proper image scale for a bar button item

拜拜、爱过 提交于 2020-01-03 09:08:18

问题


I'm trying to add my own image as a bar button item, but I don't know how to get the image to scale properly. Apple's Human Interface guidelines recommends that my image be 44x44 px, but when I use a 44x44 px image, it is too large for the toolbar, as you can see:

When I use a smaller version of the image, it looks pixellated on the Retina display. What am I supposed to do here?


回答1:


In images.xcassets, you can add the images as 1x, 2x and 3x. Xcode will use the appropriate image size depending on the device.




回答2:


You need to follow apple guidelines for designing you can find it from this link https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/MobileHIG/LayoutandAppearance.html#//apple_ref/doc/uid/TP40006556-CH54-SW1

You can find the attached screenshot image for correct sizing for the UIBarButtonItem image size as par the apple guidelines you have to use 44X44 for ratina (@2x) and 22X22 for normal (@1x) for UIBarButtonItem




回答3:


width 22 pixels X height 22 pixels - ideal for left or right BarButtonItem. You can resize any image to custom sizes using online tools, one such I used is http://www.picresize.com/



来源:https://stackoverflow.com/questions/32815490/ios-how-to-set-the-proper-image-scale-for-a-bar-button-item

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