136

我正在寻找创建自己的自定义“按日期排序”和“按数字排序”按钮,我计划将它们放在导航栏中作为右侧按钮。

我的图像应该有多大才能适当地填充空间 - UIBarItem文档页面没有列出任何有关图像大小的信息。

4

4 回答 4

242

As of iOS 11, the Human Interface Guidelines suggest glyphs be about 25×25 points in toolbars and navigation bars, up to a maximum of about 28 points. (And the HIG should definitely be in your bookmarks if you're working on iOS apps!)

That would translate to images 25px square for older devices like iPad 2 / Mini, 50px square for most current devices like iPhone 8 or iPad, and 75px square for Retina HD devices (the iPhone 6/7/8 Plus, or iPhone X). Asset catalogs will help immensely in keeping the different asset sizes organized (and Xcode can even generate them from vector sources these days).

于 2009-10-19T21:01:29.943 回答
47

自 iOS7 以来,人机界面指南告诉您

无论图标的视觉风格如何,创建以下尺寸的工具栏或导航栏图标:

约 44 x 44 像素

约 22 x 22 像素(标准分辨率)

这是所有平台资源所需大小的一个很好的矩阵

于 2014-01-29T15:43:18.680 回答
24

是的,Apple 建议使用 22 像素、44 像素和 66 像素大小的图像UIBarButtonItems,但如果您使用预安装的图标,如书签图标,则其大小分别为 25 像素、50 像素和 75 像素,用于 1x、2x 和 3x。

这里有 2 个图标UIToolbar。右边是苹果的系统书签图标,左边是我的自定义图标。

这里我的自定义图标大小为 22px-44px-66px:

在此处输入图像描述

这里是 25px-50px-75px:

在此处输入图像描述

因此,如果您在一个工具栏中使用自定义图标和系统图标,我建议使用 25px-50px-75px 缩放,否则您的自定义图标会更小。事实上,我总是使用 25px-50px-75px 缩放,它在工具栏上看起来更好,对我来说。

于 2016-08-20T14:54:15.330 回答
-4

简单:将您的图像包含在 Assets.xcassets 中。

如何?

  • 点击 Assets.xcassets
  • 单击 + 图标,然后单击“新建图像集”
  • 将图像拖放到 3x 插槽
  • 重命名图像集
  • 在 BarButton 中,您可以在“图像”字段下使用此名称
于 2015-11-04T11:54:49.300 回答