如何设置/更改UIBarButtonItem标题

时间:2016-06-14 01:29:29

标签: xamarin xamarin.ios xamarin.forms uibarbuttonitem

这是我做的例子

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);

我尝试了很多方法,但还没有解决这个问题。

1 个答案:

答案 0 :(得分:1)

试试这个:

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);