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?
推荐答案
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屋!