【问题标题】:How can I set/change the font size of UIBarButtonItem's Title如何设置/更改 UIBarButtonItem 标题的字体大小
【发布时间】:2016-06-14 19:12:27
【问题描述】:

这是我做的例子

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

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

【问题讨论】:

  • 你想改变导航栏中所有元素的字体大小吗?
  • 其实我只想改变某人屏幕右栏按钮的字体大小,这可能吗?或者更改 rightBarButton 中所有元素的 fontsize..

标签: xamarin xamarin.ios xamarin.forms uibarbuttonitem


【解决方案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);   

【讨论】:

  • 感谢您的回答!但我无法获得button.GetTitleTextAttributes(UIControlState.Application) 的值,错误告诉我它是NULL...
  • 现在好了。我测试过,是正确的。 IControlState 必须是 IControlState.Normal。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-06-07
  • 1970-01-01
  • 2022-11-13
  • 1970-01-01
  • 2014-09-25
  • 1970-01-01
  • 2019-02-05
相关资源
最近更新 更多