gpt4 book ai didi

ios - 为什么标签栏项目只显示没有图标的标题?

转载 作者:行者123 更新时间:2023-12-01 18:03:28 25 4
gpt4 key购买 nike

我创建了一个简单的 TabBarController 并将系统图像作为图标:

class TabBarController: UITabBarController {

private let profile = ProfileView()
private let explore = ExploreView()

override func viewDidLoad() {
super.viewDidLoad()
configure()
}

private func configure() {

explore.tabBarItem = UITabBarItem(
title: "Explore",
image: UIImage(named: "globe")?.withRenderingMode(.alwaysOriginal),
tag: 0
)

profile.tabBarItem = UITabBarItem(
title: "Profile",
image: UIImage(named: "person.fill")?.withRenderingMode(.alwaysOriginal),
tag: 1
)

self.viewControllers = [explore, profile]
self.selectedIndex = 0
}
}
但是当我运行该项目时,我只看到没有图标的标题。有什么问题?我发现的其他问题是面向 Storyboard的,但是如何以编程方式解决它。
enter image description here

最佳答案

改用如下
demo

    explore.tabBarItem = UITabBarItem(
title: "Explore",
image: UIImage(systemName: "globe")?.withRenderingMode(.alwaysTemplate),
tag: 0
)

关于ios - 为什么标签栏项目只显示没有图标的标题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62957004/

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