Rexluvplay
Rexluvplay

Reputation: 41

How can I set/change the font size of UIBarButtonItem's Title

Here is the example I made

self.NavigationItem.SetRightBarButtonItem(new UIBarButtonItem(Title:"want to let this text be smaller", UIBarButtonItemStyle.Plain, (object sender, EventArgs e) => webView.EvaluateJavascript ("window.location.href=")), true);

I tried so many ways but not solve this problem yet.

Upvotes: 1

Views: 1383

Answers (1)

jzeferino
jzeferino

Reputation: 7850

Try this:

var button = new UIBarButtonItem("want to let this text be smaller", UIBarButtonItemStyle.Plain, (object sender, EventArgs e) => webView.EvaluateJavascript ("window.location.href="));

var fontAttribute = new UITextAttributes();
fontAttribute.Font = UIFont.SystemFontOfSize(8);

button.SetTitleTextAttributes(fontAttribute, UIControlState.Normal);

NavigationItem.SetRightBarButtonItem(button, true);   

Upvotes: 2

Related Questions