0

In my app I'm facing one trouble, my requirement is I want to show text in single line, but response which was coming from API is like:

"Hi
Hello
How Are You"

How to convert this and display in single line in UILabel

Mr.Kushwaha
  • 491
  • 5
  • 14
Kavin Kumar Arumugam
  • 1,792
  • 3
  • 28
  • 47
  • replace occurrence of new lines. Refer this : https://stackoverflow.com/questions/28957940/remove-all-line-breaks-at-the-beginning-of-a-string-in-swift?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa – Sharad Chauhan May 18 '18 at 09:36

1 Answers1

3
var newString = myString.components(separatedBy: CharacterSet.newlines).joined(separator: " ")

Then you can bind that newString to UILabel.