iOS Swift UILabel 将两行显示为单行

iOS Swift UILabel Display Two Lines into Single Line

在我的应用程序中,我遇到了一个麻烦,我的要求是我想在单行中显示文本,但是来自 API 的响应如下:

"Hi
Hello
How Are You"

如何转换它并在 UILabel

中以单行显示
var newString = myString.components(separatedBy: CharacterSet.newlines).joined(separator: " ")

然后您可以将该 newString 绑定到 UILabel。