我正在寻找创建自己的自定义“按日期排序”和“按数字排序”按钮,我计划将它们放在导航栏中作为右侧按钮。
我的图像应该有多大才能适当地填充空间 - UIBarItem文档页面没有列出任何有关图像大小的信息。
我正在寻找创建自己的自定义“按日期排序”和“按数字排序”按钮,我计划将它们放在导航栏中作为右侧按钮。
我的图像应该有多大才能适当地填充空间 - UIBarItem文档页面没有列出任何有关图像大小的信息。
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).
是的,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 缩放,它在工具栏上看起来更好,对我来说。
简单:将您的图像包含在 Assets.xcassets 中。
如何?