ios swift UITabBarController UITabBarItem UITabBar

import UIKit

class TabBarVC: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        tabBar.tintColor = UIColor.mainColor

        selectedIndex = 1

        let itemRecord: UITabBarItem = tabBar.items![0]
        let itemEquipment: UITabBarItem = tabBar.items![1]
        let itemMine: UITabBarItem = tabBar.items![2]
        
        itemRecord.title = NSLocalizedString("record", comment: "")
        itemEquipment.title = NSLocalizedString("equipment", comment: "")
        itemMine.title = NSLocalizedString("me", comment: "")
    
        
        itemRecord.image = UIImage(named: "record")
        itemRecord.selectedImage = UIImage(named: "recordSelect")?.withRenderingMode(.alwaysOriginal)
        itemEquipment.image = UIImage(named: "equipment")
        itemEquipment.selectedImage = UIImage(named: "equipmentSelect")?.withRenderingMode(.alwaysOriginal)
        itemMine.image = UIImage(named: "mine")
        itemMine.selectedImage = UIImage(named: "mineSelect")?.withRenderingMode(.alwaysOriginal)
    }
    

参考博客:
UITabBar 设置选中、未选中状态下title的字体颜色
iOS设置tabBarItem图片渲染模式

相关推荐
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页