xcode 如何减小 UI 选项卡栏项目图像的大小以使其适合选项卡栏?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29708069/
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
How can I decrease the size of a UI Tab Bar Item Image so that it fits inside the Tab bar?
提问by TW80000
This is for a tab bar for an iPhone app, using the Swift coding language in Xcode 6.3
这是用于 iPhone 应用程序的标签栏,使用 Xcode 6.3 中的 Swift 编码语言
My issue is that I want to add an image into my Tab bar in one of my view controllers, but the image is too large. My original solution to this was to manually decrease the size of the image using preview, but the resolution was poor after doing that. Is there a line of code that I can put into the app delegate that could resize an image without changing the source file? Does anyone know of any other way to solve this problem?
我的问题是我想在我的一个视图控制器的 Tab 栏中添加一个图像,但图像太大了。我最初的解决方案是使用预览手动减小图像的大小,但这样做后分辨率很差。是否有一行代码可以放入应用程序委托中,可以在不更改源文件的情况下调整图像大小?有谁知道解决这个问题的任何其他方法?
The second image is the goal, but without the resolution loss.
第二张图像是目标,但没有分辨率损失。
回答by Swapnil Luktuke
This is not possible.
这不可能。
Check Icon and Image Sizes guidelinesfrom apple. It categorically mentions:
检查来自苹果的图标和图像大小指南。它明确提到:
Unlike other custom artwork in your app, the icons and images listed in Table 41-1 must meet specific criteria so that iOS can display them properly.
与应用程序中的其他自定义图稿不同,表 41-1 中列出的图标和图像必须满足特定条件,以便 iOS 能够正确显示它们。
This applies to the tab bar icons too. So, if your images are larger than the max size (mentioned in above link), you will face such issues. Better resize the images.
这也适用于标签栏图标。因此,如果您的图像大于最大尺寸(在上面的链接中提到),您将面临此类问题。更好地调整图像大小。
If you are worried about poor resolution on retina displays (6, 6+ etc), make sure you provide @2x and @3x images for each tab bar image to Support the Retina display.
如果您担心 Retina 显示器(6、6+ 等)的分辨率不佳,请确保为每个标签栏图像提供 @2x 和 @3x 图像以支持 Retina 显示器。