gpt4 book ai didi

ios - 自定义 UITabBar 图标 iOS

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:58:44 29 4
gpt4 key购买 nike

我正在开发一个选项卡式应用程序,我想集成自定义 UITabbar 背景和图标。我已经插入了自定义背景,但图标有问题。

图标应该是这样的:

enter image description here

但是在 Storyboard中为每个 View 添加图标后,我得到这样的灰色图标:

enter image description here

有谁知道为什么图标会这样显示?

非常感谢!

最佳答案

使用 Xcode 6,为了能够直接从 Storyboard 更改图像,您可以这样做:

@IBDesignable class CustomizedTabBarItem: UITabBarItem {
@IBInspectable var finalImage:UIImage = UIImage() {
didSet {
self.image = finalImage.imageWithRenderingMode(.AlwaysOriginal)
}
}
@IBInspectable var finalSelectedImage:UIImage = UIImage() {
didSet {
self.selectedImage = finalSelectedImage.imageWithRenderingMode(.AlwaysOriginal)
}
}
}

之后,您只需在 Storyboard中设置图像 enter image description here

关于ios - 自定义 UITabBar 图标 iOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18742734/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com