ios TabBar 图像应该是什么尺寸?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18068597/
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
What size should TabBar images be?
提问by Fahim Parkar
I have icons for a tabBar of size 100.
我有一个大小为 100 的 tabBar 的图标。
I checked at Apple's Human Interface Guidelines of 2013and it says the image size should be 30x30
/ 60x60
.
我查看了 Apple 的 2013 年人机界面指南,它说图像大小应该是30x30
/ 60x60
。
But as the height of tab bar controller is 50, I kept the size of the image at 50x50
.
但是由于标签栏控制器的高度为 50,我将图像的大小保持在50x50
.
Now, when I run the project, I see the ugly design below:
现在,当我运行该项目时,我看到下面丑陋的设计:
Any idea what size images I should use so that the design will be perfect?
知道我应该使用什么尺寸的图像才能使设计完美吗?
Note:I am not writing text also (e.g. Home, Search, etc). The text of the tab button is there in the image itself.
注意:我也不是在写文本(例如主页、搜索等)。选项卡按钮的文本位于图像本身中。
回答by rsc
According to the Apple Human Interface Guidelines:
根据苹果人机界面指南:
@1x : about 25 x 25 (max: 48 x 32)
@1x:约 25 x 25(最大:48 x 32)
@2x : about 50 x 50 (max: 96 x 64)
@2x:约 50 x 50(最大:96 x 64)
@3x : about 75 x 75 (max: 144 x 96)
@3x:约 75 x 75(最大:144 x 96)
回答by garrettmurray
30x30 is points, which means 30px @1x, 60px @2x, not somewhere in-between. Also, it's not a great idea to embed the title of the tab into the image—you're going to have pretty poor accessibility and localization results like that.
30x30 是点,这意味着 30px @1x,60px @2x,而不是介于两者之间。此外,将选项卡的标题嵌入到图像中也不是一个好主意——这样的可访问性和本地化结果会很差。
回答by Mihir Oza
According to the latest Apple Human Interface Guidelines:
根据最新的苹果人机界面指南:
In portrait orientation, tab bar icons appear above tab titles. In landscape orientation, the icons and titles appear side-by-side. 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.
在纵向中,标签栏图标出现在标签标题上方。在横向模式下,图标和标题并排显示。根据设备和方向,系统会显示常规或紧凑的标签栏。您的应用应包含两种尺寸的自定义标签栏图标。
I suggest you to use the above link to understand the full concept. Because apple update it's document in regular interval
我建议您使用上面的链接来了解完整的概念。因为苹果定期更新它的文档
回答by Allen
参考:https: //developer.apple.com/ios/human-interface-guidelines/graphics/custom-icons/[https://developer.apple.com/ios/human-interface-guidelines/graphics/custom-icons /]。
So the 50x50 size is a good choice.
所以50x50的尺寸是一个不错的选择。
回答by firelyu
According to my practice, I use the 40 x 40 for standard iPad tab bar item icon, 80 X 80 for retina.
根据我的实践,我使用 40 x 40 的标准 iPad 标签栏项目图标,80 X 80 的视网膜。
From the Apple reference. https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/MobileHIG/BarIcons.html#//apple_ref/doc/uid/TP40006556-CH21-SW1
If you want to create a bar icon that looks like it's related to the iOS 7 icon family, use a very thin stroke to draw it. Specifically, a 2-pixel stroke (high resolution) works well for detailed icons and a 3-pixel stroke works well for less detailed icons.
如果您想创建一个看起来与 iOS 7 图标系列相关的条形图标,请使用非常细的笔画来绘制它。具体来说,2 像素笔画(高分辨率)适用于细节丰富的图标,而 3 像素笔画适用于不太详细的图标。
Regardless of the icon's visual style, create a toolbar or navigation bar icon in the following sizes:
无论图标的视觉风格如何,都可以创建以下尺寸的工具栏或导航栏图标:
About 44 x 44 pixels About 22 x 22 pixels (standard resolution) Regardless of the icon's visual style, create a tab bar icon in the following sizes:
约 44 x 44 像素约 22 x 22 像素(标准分辨率) 不管图标的视觉风格如何,创建以下尺寸的标签栏图标:
About 50 x 50 pixels (96 x 64 pixels maximum) About 25 x 25 pixels (48 x 32 pixels maximum) for standard resolution
约 50 x 50 像素(最大 96 x 64 像素) 标准分辨率约 25 x 25 像素(最大 48 x 32 像素)
回答by James
Thumbs up first before use codes please!!! Create an image that fully cover the whole tab bar item for each item. This is needed to use the image you created as a tab bar item button. Be sure to make the height/width ratio be the same of each tab bar item too. Then:
使用代码前请先点赞!!!为每个项目创建一个完全覆盖整个标签栏项目的图像。这是将您创建的图像用作选项卡栏项目按钮所必需的。确保每个标签栏项目的高/宽比也相同。然后:
UITabBarController *tabBarController = (UITabBarController *)self;
UITabBar *tabBar = tabBarController.tabBar;
UITabBarItem *tabBarItem1 = [tabBar.items objectAtIndex:0];
UITabBarItem *tabBarItem2 = [tabBar.items objectAtIndex:1];
UITabBarItem *tabBarItem3 = [tabBar.items objectAtIndex:2];
UITabBarItem *tabBarItem4 = [tabBar.items objectAtIndex:3];
int x,y;
x = tabBar.frame.size.width/4 + 4; //when doing division, it may be rounded so that you need to add 1 to each item;
y = tabBar.frame.size.height + 10; //the height return always shorter, this is compensated by added by 10; you can change the value if u like.
//because the whole tab bar item will be replaced by an image, u dont need title
tabBarItem1.title = @"";
tabBarItem2.title = @"";
tabBarItem3.title = @"";
tabBarItem4.title = @"";
[tabBarItem1 setFinishedSelectedImage:[self imageWithImage:[UIImage imageNamed:@"item1-select.png"] scaledToSize:CGSizeMake(x, y)] withFinishedUnselectedImage:[self imageWithImage:[UIImage imageNamed:@"item1-deselect.png"] scaledToSize:CGSizeMake(x, y)]];//do the same thing for the other 3 bar item