Douglas
Douglas

Reputation: 2524

iOS scope bar font SIZE?

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.

Upvotes: 0

Views: 852

Answers (2)

Mehrdadmaskull
Mehrdadmaskull

Reputation: 163

Swift 3:

   searchBar.setScopeBarButtonTitleTextAttributes([NSFontAttributeName: UIFont(name: "HelveticaNeue-Medium", size: 15.0)!], for: .normal)

Upvotes: 1

Dmitriy Kalachniuk
Dmitriy Kalachniuk

Reputation: 372

Just use

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

Upvotes: 2

Related Questions