Material-components-ios: [Tabs] how Should i change the font family and font size in the tabbar (UITabBarItem) title?

Created on 25 May 2018  路  14Comments  路  Source: material-components/material-components-ios

Feature Request/Suggestion

I need to change my title font family to custom font family, which is showing in the title.. please tell.!.... i am using in swift.!

[Tabs] Question

Most helpful comment

Great! Glad to hear you worked it out. :)

All 14 comments

The title doesn't have a [Component] prefix.

then is it possible to change the custom fonts.!
?

Hi @HariNarayanan777 , I'm guessing that this is for either MDCBottomNavigationBar or MDCTabBar.

For MDCBottomNavigationBar, you can use -[MDCBottomNavigationBar itemTitleFont].
For MDCTabBar, you can use -[MDCTabBar unselectedItemTitleFont] and -[MDCTabBar selectedItemTitleFont].

Please feel free to reopen this issue if it doesn't answer your question. Thanks for using MDC-iOS!

can you please tell in swift language..
i used swift only.. Please tell.!

Hi Hari, you can use the same properties in Swift and Objective-C: itemTitleFont, selectedItemTitleFont and unselectedItemTitleFont. They are not named differently in Swift.

But i cannot get this @romoore
i used the below code

let tabBar = MDCTabBar.init(frame: CGRect(x: 0, y: 4, width: self.view.frame.size.width, height: 0))

and there is no suggestion from the tabBar.selectedItemTitleFont
its showing Value of type 'MDCTabBar' has no member 'selectedItemTitleFont'
please show me some example for this..

I modified the example, TabBarIconExample.swift do set the selectedItemTitleFont to a point size 99.

let tabBar = MDCTabBar()
tabBar.selectedItemTitleFont = UIFont.systemFont(ofSize: 99)

simulator screen shot - iphone 4s - 2018-05-25 at 09 30 54

Just as a double-check, what version of MDC-iOS are you using? Customized fonts support was added in December, 2017, so if you don't see the property in the header you may have an older version of the library.

yeah i think its an old modal, may i know how to check the version which i used.?
i am currently used only

pod 'MaterialComponents/Tabs' this pod.

Now i am using MaterialComponents, 54.7.0

54.7.0 should have both of those properties available. Can you please post a small self-contained example? A basic Xcode project with minimal code to demonstrate the bug would be very helpful.

@HariNarayanan777 I appreciate your trying to use MDC-iOS, but I think this type of problem is probably best suited for a StackOverflow question.

@romoore thank you so much for you replies
i just uninstall the pod and then install it again in my project this would perfect now.. really #super..
now i can able to change the custom font family and font size itself.... Thank you..

Great! Glad to hear you worked it out. :)

Was this page helpful?
0 / 5 - 0 ratings