我创建了一个简单的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
}
}
但是当我运行项目时,我只会看到没有图标的标题。怎么了我发现的其他问题是针对情节提要的,但如何以编程方式解决。