【问题标题】:Button with three line text in iOS 10 XamariniOS 10 Xamarin 中带有三行文本的按钮
【发布时间】:2017-09-10 09:30:29
【问题描述】:

我将三行字符串标题设置为 UIButton。我使用的是 iOS 10。但我无法设置。

我尝试过的。

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

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

\n 不会将字符串换行。

并将 UIButton 属性设置为 WordWrap

  1. 当我设置时

    noOfLineTitleLabelUIButton 但 noOfLine 属性是 not display

屏幕截图:

查看屏幕截图:

First one is UIButton 但它的显示效果不如我接受的那样。

Second one is UILabel 显示效果符合我的预期。

我想把它设置为第二个。

有没有办法像第二个一样设置它。

感谢任何帮助。

【问题讨论】:

  • 请使用 setAttributedTitle 代替 UIButton 的 setTitle 方法。

标签: ios button xamarin.ios uibutton multiline


【解决方案1】:

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

查看屏幕截图:

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

输出符合预期。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多