Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.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 创建并初始化自定义UItabaritem类_Ios_Swift_Uitabbar_Uitabbaritem - Fatal编程技术网

Ios 创建并初始化自定义UItabaritem类

Ios 创建并初始化自定义UItabaritem类,ios,swift,uitabbar,uitabbaritem,Ios,Swift,Uitabbar,Uitabbaritem,我正在用四个uitabaritems构建一个应用程序。它们看起来都应该一样。我没有在各自的UIViewController中自定义它们,而是尝试构建一个自定义的uitabaritem类,并让uitabaritems从中继承 到目前为止,我所做的工作如下: class CustomTabBarItem: UITabBarItem { func customiseTabBarItems() { // Customises the item on the tab bar

我正在用四个
uitabaritems
构建一个应用程序。它们看起来都应该一样。我没有在各自的
UIViewController
中自定义它们,而是尝试构建一个自定义的
uitabaritem
类,并让
uitabaritems
从中继承

到目前为止,我所做的工作如下:

class CustomTabBarItem: UITabBarItem {


    func customiseTabBarItems() {
        // Customises the item on the tab bar

        // For normal state
       setTitleTextAttributes([NSAttributedStringKey.font : Fonts.small!, NSAttributedStringKey.foregroundColor: Colours.grey], for: .normal)

        // When highlighted
       setTitleTextAttributes([NSAttributedStringKey.font : Fonts.small!, NSAttributedStringKey.foregroundColor: Colours.white], for: .highlighted)
    }


}
我在故事板中将每个
uitabaritem
设置为我的“CustomTabBarItem”的子类

但是,问题是,我的
uitabaritems
没有显示该功能

有什么建议吗

我正在构建一个具有四个uitabaritem的应用程序。它们看起来都应该一样

实现这一点的方法不是尝试某种uitabaritem子类,而是使用for uitabaritem。例如:

UITabBarItem.appearance().setTitleTextAttributes( // ...

在您的应用程序中执行此操作。delegate
didFinishLaunching
。所有选项卡栏项目都将根据您对外观代理的命令进行自定义。

如果您只想更改项目的颜色,可以通过情节提要轻松完成