简体   繁体   English

标签栏图标大小

[英]Tab Bar Icon Size

Apple says : 苹果

Depending on the device and orientation, the system displays either a regular or compact tab bar. 根据设备和方向,系统会显示常规或紧凑的选项卡栏。 Your app should include custom tab bar icons for both sizes. 您的应用应包含两种尺寸的自定义标签栏图标。

Unfortunately, they fail to specify when you get which. 不幸的是,他们无法指定何时获得。

Also I might include those images for both sizes, but will the system switch between them automatically (how?) or do I have to do it myself? 另外,我可能会同时包含这两种尺寸的图像,但是系统会自动在它们之间切换(如何?)还是我必须自己做?

You should not do this yourself system can do it automatically. 您不应该自己执行此操作,否则系统可以自动执行此操作。

here is Apple Human Interface Guidelines, where you can find icon resolutions: https://developer.apple.com/ios/human-interface-guidelines/icons-and-images/custom-icons/ 这是Apple人机界面指南,可在其中找到图标分辨率: https : //developer.apple.com/ios/human-interface-guidelines/icons-and-images/custom-icons/

for example: If you are using circular icons for tab bar item you should create following sizes for portrait mode: 例如:如果将圆形图标用于标签栏项目,则应为纵向模式创建以下尺寸:

  • 75px × 75px (25pt × 25pt @3x) 75px×75px(25pt×25pt @ 3x)
  • 50px × 50px (25pt × 25pt @2x) 50px×50px(25pt×25pt @ 2x)
  • 25px × 25px (25pt × 25pt @1x) 25px×25px(25pt×25pt @ 1x)

and for landscape mode: 对于横向模式:

  • 54px × 54px (18pt × 18pt @3x) 54px×54px(18pt×18pt @ 3x)
  • 36px × 36px (18pt × 18pt @2x) 36px×36px(18pt×18pt @ 2x)
  • 18px × 18px (18pt × 18pt @1x) 18px×18px(18pt×18pt @ 1x)

after you add this icons into Assets.xcassets or somewhere, you can select Tab Bar Item icons from storyboard: 在将此图标添加到Assets.xcassets或某处之后,可以从情节提要中选择“选项卡栏项”图标:

select Tab Bar item and in the attributes inspector, choose portrait image for image field, and landscape image for landscape field. 选择“标签栏”项,然后在属性检查器中,选择“纵向”图像作为图像字段,并选择“横向”图像作为横向字段。

After that system will do everything for you. 之后,该系统将为您做所有事情。

在此处输入图片说明

Unfortunately, the compact/regular state does not only depend from the orientation or the app window size, it also depends on the device. 不幸的是,紧凑/常规状态不仅取决于方向或应用程序窗口的大小,还取决于设备。

You can find a regular/compact size breakdown here for different devices. 您可以在此处找到针对不同设备的常规/紧凑型尺寸细分。 You should look for the second value (for eg Compact width, regular height ). 您应该寻找第二个值 (例如紧凑宽度, 常规高度 )。

The change happens between the two types of icons automatically , as soon as the orientation/app window changes. 方向/应用程序窗口更改后,就会自动在两种类型的图标之间进行更改。

TLDR : You can specify different icons for regular or compact tab bar in Asset Catalog by setting Width Class to Any & Compact. TLDR :您可以通过将Width Class设置为Any&Compact为资产目录中的常规或紧凑标签栏指定不同的图标。

Yes, according to Human Interface Guidelines Custom Icons - Tab Bar Icon Size you should include both icon sizes 是的,根据《人机界面指南自定义图标-标签栏图标大小》,您应同时包含两个图标大小

In portrait orientation, tab bar icons appear above tab titles¹. 纵向放置时,标签栏图标会显示在标签标题上方¹。 In landscape orientation, the icons and titles appear side-by-side. 横向放置时,图标和标题并排出现。

¹⁾ This is true only on iPhone. ¹⁾ 仅在iPhone上如此。 On iPad for full-screen apps the icons and titles appear side-by-side in both portrait and landscape orientations. 在用于全屏应用程序的iPad上,图标和标题以纵向和横向并排显示。

Depending on the device and orientation, the system displays either a regular or compact tab bar. 根据设备和方向,系统会显示常规或紧凑的选项卡栏。 Your app should include custom tab bar icons for both sizes. 您的应用应包含两种尺寸的自定义标签栏图标。

The guidelines are talking about Size Classes . 该准则讨论的是大小类 In this case regular or compact tab bar means tab bar in regular or compact width size class. 在这种情况下,常规或紧凑型标签栏是指常规或紧凑宽度尺寸等级的标签栏。

You can specify different images for different size classes in the asset catalog. 您可以在资产目录中为不同尺寸的类别指定不同的图像。 Just set Width class to Any & Compact in the Attributes Inspector for you tab bar icon Image Set: 只需在Attributes Inspector中为您将Width class设置为Any & Compact标签栏图标图像集:

宽度等级-任何和紧凑

Set the larger images for regular size class in the Any Width section and smaller images for compact size class in Compact Width section. 在“任意宽度”部分为常规尺寸类别设置较大的图像,在“紧凑宽度”部分为紧凑尺寸类别设置较小的图像。

The system will then automatically show the correct image according to the size class (device, orientation, multitasking configuration). 然后,系统将根据尺寸类别(设备,方向,多任务配置) 自动显示正确的图像

You can find the correct icon sizes for the icons in Human Interface Guidelines Custom Icons - Tab Bar Icon Size . 您可以在《人机界面指南自定义图标-标签栏图标大小 》中找到正确的图标大小。

For example for a circular glyph the icon should be: 例如,对于圆形字形,图标应为:

  • 25x25 pt (50x50 px @2x) for regular tab bars 25x25磅(50x50像素@ 2x)用于常规标签栏
  • 18x18 pt (36x36 px @2x) for compact tab bars 紧凑型标签栏为18x18 pt(36x36 px @ 2x)

For a square glyph the icon should be: 对于方形字形,图标应为:

  • 23x23 pt (46x46 px @2x) for regular tab bars 常规标签栏为23x23 pt(46x46 px @ 2x)
  • 17x17 pt (34x34 px @2x) for compact tab bars 17x17磅(34x34像素@ 2x)用于紧凑型标签栏

There are additional sizes for wide glyphs and tall glyphs. 对于宽字形和高字形,还有其他尺寸。

In the screenshot above I use PDF images with Scale set to Single Scale in the Attributes Inspector. 在上面的屏幕截图中,我使用了在“属性”检查器中将“ 比例”设置为“ Single Scale PDF图像。 The system automatically generates 1x, 2x and 3x PNGs. 系统会自动生成1x,2x和3x PNG。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM