iOS 10 Xamarin 中带有三行文本的按钮

Button with three line text in iOS 10 Xamarin

我正在为 UIButton 设置三行字符串标题。我用的是iOS10,但是设置不了

我试过的。

  1. 使用以下字符串设置 UIButton 标题标签。

    String = "Before\n-\n12:00".

但是 \n 不会将字符串换行。

并将 UIButton 属性 设置为 WordWrap

  1. 当我设置

    noOfLineUIButtonTitleLabel 但 noOfLine 属性 是 not display.

截图:

查看屏幕截图:

First one is UIButton 但显示效果不佳。

Second one is UILabel 显示效果如我所料。

我想把它设置成第二个。

有什么方法可以设置成Second One吗

感谢任何帮助。

我找到的一个解决方案如下

查看屏幕截图:

在 UIButton 中将 Title 设置为 Attributed 并将 Title 设置为 centre.

输出符合预期。