TabBarItems 并设置它们的图像大小? [英] TabBarItems and setting their image sizes?
问题描述
我目前正在为我的每个标签栏项目添加图像.我喜欢的一张图片的尺寸比酒吧项目的面积大得多.当我在情节提要中设置条形项目的图像并运行模拟器时......带有该图像的条形按钮覆盖整个屏幕.
I am currently adding images to each one of my tab bar items. One image I like has a size that is much bigger then the area of the bar item. When I set the image of the bar item in the storyboard and run the emulator... the bar button with that image covers the entire screen.
现在我想有一些自动的方法可以让图像为每个条形按钮调整大小.遗憾的是,情况并非如此.有没有办法在标签栏加载时调整每个标签栏中的图像大小?
Now I thought there was some automatic way of allowing the images to resize for each bar button. This is sadly not the case. Is there a way when the tab bar loads that I can resize the images within each tab bar?
推荐答案
你应该为每个标签栏项准备 3 个图像图标 (1x、2x 和 3x).
You should prepare 3 images icons for each tab bar item (1x, 2x and 3x).
首先在 75w 75h 像素处创建 3x(最大:144 x 96)并将其保存为 iconTab0@3x.png.
First create the 3x at 75w 75h pixels (maximum: 144 x 96) and save it as iconTab0@3x.png.
然后将其调整为 50w 50h 像素(最大:96 x 64)并将其保存为 iconTab0@2x.png.
Then resize it to 50w 50h pixels (maximum: 96 x 64) and save it as iconTab0@2x.png.
最后将其调整为 25w 25h 像素(最大:48 x 32)并将其保存为 iconTab0.png.
Finally resize it to 25w 25h pixels (maximum: 48 x 32) and save it as iconTab0.png.
现在您只需要在取景器中选择这 3 张图片,然后将它们拖到您的图片资源中即可.
Now all you need is to select those 3 images at your finder and drag them to your image assets.
这篇关于TabBarItems 并设置它们的图像大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!