Swift和Xcode - 如何创建自定义选项卡栏图标 [英] Swift and Xcode - How to Create Custom Tab Bar Icons

查看:180
本文介绍了Swift和Xcode - 如何创建自定义选项卡栏图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个标签式应用程序项目,我正在使用Swift编写的Xcode( Xcode 6.3和Swift 1.2 )。我在使用自定义标签栏图标时遇到了很多麻烦。我在Photoshop(CS6)中设计了一个图像,将其保存为PNG,在Prepo中将其调整为 30x30 并将其导入资产库中的Xcode。然后,我将选项卡视图控制器图标设置为该图像。但是,它没有出现。

I have a tabbed application project I am working on in Xcode written in Swift (Xcode 6.3 and Swift 1.2). I am having a lot of trouble with custom Tab Bar icons. I have designed an image in Photoshop (CS6), saved it as a PNG, resized it in Prepo to be 30x30 and imported it into Xcode in the asset library. I then set the tab view controllers icon to that image. However, it doesn't show up.

我查看过这些页面但没有找到任何帮助:

https://www.youtube.com/watch?v=4qqqoAWNfZA
自定义标签栏图标颜色
http://www.raywenderlich.com/forums/viewtopic.php?f=2&t=19333

b $ b http://www.appcoda。 com / ios-programming-how-to-customize-tab-bar-background-appearance /
https://www.youtube.com/watch?v=4Tj_SeApUrs

I have looked at these pages but not found any help:
https://www.youtube.com/watch?v=4qqqoAWNfZA Custom tab bar icon colors http://www.raywenderlich.com/forums/viewtopic.php?f=2&t=19333
http://www.appcoda.com/ios-programming-how-to-customize-tab-bar-background-appearance/ https://www.youtube.com/watch?v=4Tj_SeApUrs

创建自定义标签栏图标的正确流程是什么?

What is the proper process to create custom tab bar icons?

推荐答案

经过一段时间的r esearch我解决了这个问题,所以我想在这里发帖以防其他人有类似的问题。在Photoshop中我做了以下工作:

After a bit of research I resolved the issue, so thought I'd post here in case anyone else has a similar issue. In Photoshop I did the following:


  1. 导入我想用作标签栏图标的图像(如果你使用黑色和白色图像,以便您不必删除颜色。)

  2. 将背景设置为透明而不是白色。

  3. 删除所有白色从图像中,它只是一个透明背景的黑色图像。

  4. 将图像保存为.png。

  5. 将图像调整为是一个尺寸 75x75像素的广场(并命名为 imageName@3x.png ), 50x50像素(并命名为 imageName@2x.png ), 25x25像素(并命名 imageName.png

  1. Imported the image I wanted to use as the tab bar icon (its easier if you use a black and white image so that you don't have to remove colour).
  2. Set the background to 'Transparent' rather than white.
  3. Removed all white from the image so that it was just a black image with a transparent background.
  4. Saved the image as a .png.
  5. Resized the image to be a square with dimensions 75x75 pixels (and named imageName@3x.png), 50x50 pixels (and named imageName@2x.png), and 25x25 pixels (and named imageName.png)

在Xcode中,我做了以下内容:

In Xcode I did the following:


  1. 将图像拖动到Xcode中,并将图像组重命名为 icoImageName

  2. 在Xcode的故事板中选择我想要设置图像的选项卡并设置'Image '(在Inspector窗格中的'Bar Item'下)到 icoImageName 。请注意,我没有在'Tab Bar Item'下设置'Selected Image'(留空)。

  1. Dragged the images into Xcode and renamed the image group as icoImageName.
  2. Selected the tab I wanted to set the image for in the storyboard in Xcode and set the 'Image' (under 'Bar Item' in the Inspector Pane) to icoImageName. Note that I did not set the 'Selected Image' under the 'Tab Bar Item' (leave this blank).

完成。

我希望这有助于某人。感谢大家的帮助。

I hope this helps someone. Thanks to everyone for their help as well.

这篇关于Swift和Xcode - 如何创建自定义选项卡栏图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆