xcode iOS:如何为条形按钮项设置适当的图像比例

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32815490/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 07:57:09  来源:igfitidea点击:

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

iosxcodeuibarbuttonitem

提问by yesthisisjoe

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:

我正在尝试将我自己的图像添加为条形按钮项,但我不知道如何使图像正确缩放。Apple 的人机界面指南建议我的图像为 44x44 像素,但是当我使用 44x44 像素的图像时,它对于工具栏来说太大了,如您所见:

Example

例子

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

当我使用较小版本的图像时,它在 Retina 显示屏上看起来像素化。我应该在这里做什么?

回答by goodcow

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

在 images.xcassets 中,您可以将图像添加为 1x、2x 和 3x。Xcode 将根据设备使用适当的图像大小。

回答by mrunal thanki

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

你需要遵循苹果设计指南,你可以从这个链接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 UIBarButtonItementer image description here

您可以找到附加的屏幕截图图像,以正确调整 UIBarButtonItem 图像大小的大小,与苹果指南一样,您必须使用 44X44 用于拉蒂娜 (@2x) 和 22X22 用于 UIBarButtonItem 的正常 (@1x)在此处输入图片说明

回答by Naishta

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/

width 22 pixels X height 22 pixels- 左侧或右侧 BarButtonItem 的理想选择。您可以使用在线工具将任何图像调整为自定义尺寸,我使用的一个是 http://www.picresize.com/