setTitleTextAttributes  not working in IOS 13 later:

 

改到 IOS 13 後突然發生 

UINavigationController  和   UITabBarController  組合起來原本正常的導覽列文字顏色不正確

找了半天才發現

 

 if (@available(iOS 13.0, *)) {

        UITabBarAppearance *standardAppearance = [[UITabBarAppearance alloc] init];

        UITabBarItemAppearance *inlineLayoutAppearance = [[UITabBarItemAppearance alloc] init];

        [ inlineLayoutAppearance.normal setTitleTextAttributes:@{  NSForegroundColorAttributeName:[ColorHandler getColorWithR:TXT_MENU_R g:TXT_MENU_G b:TXT_MENU_B a:SOLID_A]}];

        [ inlineLayoutAppearance.selected setTitleTextAttributes:@{ NSForegroundColorAttributeName:[UIColor whiteColor]}];

        standardAppearance.stackedLayoutAppearance = inlineLayoutAppearance;

        standardAppearance.backgroundColor = [ColorHandler getColorWithR:TEXT_TITLE02_R g:TEXT_TITLE02_G b:TEXT_TITLE02_B a:SOLID_A];

        tabBarController.tabBar.standardAppearance = standardAppearance;

        //TXT_MENU_R

    } else {

        // Fallback on earlier versions

    }

    全站熱搜

    喵兒貴 發表在 痞客邦 留言(0) 人氣()