Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios Can';无法查看选项卡栏图像_Ios_Swift_Xcode_Uitabbar - Fatal编程技术网

Ios Can';无法查看选项卡栏图像

Ios Can';无法查看选项卡栏图像,ios,swift,xcode,uitabbar,Ios,Swift,Xcode,Uitabbar,当我模拟我的应用程序时,我看不到选项卡栏图像 我尝试更改“渲染为原始图像”解决方案,但没有成功 import UIKit class TabBarController: UITabBarController { override func viewDidLoad() { super.viewDidLoad() setupTabBar() tabBar.barTintColor = UIColor(red: 0.1255, green:

当我模拟我的应用程序时,我看不到
选项卡栏
图像

我尝试更改“渲染为原始图像”解决方案,但没有成功

import UIKit

class TabBarController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        setupTabBar()
        tabBar.barTintColor = UIColor(red: 0.1255, green: 0.1608, blue: 0.149, alpha: 1)
    }

    func setupTabBar() {

        let homeController = UINavigationController(rootViewController: HomeViewController())
        homeController.tabBarItem.image = UIImage(named: "homeglyph_green")
        homeController.tabBarItem.selectedImage = UIImage(named: "homeglyph_lightgreen")

        let statsController = UINavigationController(rootViewController: StatsViewController())
        statsController.tabBarItem.image = UIImage(named: "statsglyph_green")
        statsController.tabBarItem.selectedImage = UIImage(named: "statsglyph_lightgreen")

        viewControllers = [homeController, statsController]
        guard let items = tabBar.items else { return }
        for item in items {
            item.imageInsets = UIEdgeInsets(top: 4, left: 0, bottom: -4, right: 0)
        }
    }
}

确保图像名称与图像资源中的商店名称相同

如果名称相同,则打开图像资源

1) 选择您的图像

2) 进行图像设置

3) 将“渲染为默认值”选项更改为“模板图像”并运行project

希望能完全帮助解决这个问题


您确定您的
UIImage(名为:“…”)
不是零吗?尝试设置断点或简单地打印这些UIImages确保您的图像资产具有使用名称的图像。