Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

i pad tab bar unselected item color is not changing but working fine in iphone

i am using xcode version 14.3.1 . Minimum deployment target 12.0. in iphone everything is just working fine but in the i pad selected item color is changing but unselected item color is not changing.

i want to get the selected unselected color in ipad too

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

let tabBarAppearnace = UITabBarAppearance()
let tabFont =  UIFont.boldSystemFont(ofSize: 16)
let selectedAttributes: [NSAttributedString.Key: Any] = [NSAttributedString.Key.font: tabFont, NSAttributedString.Key.foregroundColor: UIColor.white]

let normalAttributes: [NSAttributedString.Key: Any]
        = [NSAttributedString.Key.font: tabFont, NSAttributedString.Key.foregroundColor: UIColor.red]

tabBarAppearnace.stackedLayoutAppearance.normal.titleTextAttributes = normalAttributes
        tabBarAppearnace.stackedLayoutAppearance.selected.titleTextAttributes = selectedAttributes

tabBar.standardAppearance = tabBarAppearnace

If the above doesn’t work try the below mentioned code

tabBarAppearnace.inlineLayoutAppearance.normal.titleTextAttributes = normalAttributes
tabBarAppearnace.inlineLayoutAppearance.selected.titleTextAttributes = selectedAttributes

tabBarAppearnace.compactInlineLayoutAppearance.normal.titleTextAttributes = normalAttributes
tabBarAppearnace.compactInlineLayoutAppearance.selected.titleTextAttributes = selectedAttributes
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading