Question

I have implemented a search bar in my UITableview. I have also added a scope bar. However, the words that I am placing in the titles of the five different titles, don't fit. I looked on the Dev center to read the docs and have only come up with,

scopeBarButtonTitleTextAttributesForState:

This method will allow you to change the font, text color, text shadow color, and text shadow offset. But that is it, no font size. I even tried to write,

self.searchDisplayController.searchBar.scopeButtonTitles.font.size

Of course that just does not work! Does anyone know of a way to make a smaller font so that the words appear in their entirety?

Or.. does this just not exists and I must choose shorter words? Thanks for any insight you may have.

Was it helpful?

Solution

Just use

[self.searchBar setScopeBarButtonTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont fontWithName:@"HelveticaNeue-Medium" size:15], NSFontAttributeName, nil] forState:UIControlStateNormal];

OTHER TIPS

Swift 3:

   searchBar.setScopeBarButtonTitleTextAttributes([NSFontAttributeName: UIFont(name: "HelveticaNeue-Medium", size: 15.0)!], for: .normal)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top