Home  >  Q&A  >  body text

ios - UILabel 的text中,能识别换行符吗

@IBOutlet var lable: UILable?
lable.text = "asdfasdfasdfasdf"

能否在 字符串中间加入 "\n" 这样的换行符呢?

希望能够给出稍微详细一些的回答

PHP中文网PHP中文网2741 days ago680

reply all(2)I'll reply

  • ringa_lee

    ringa_lee2017-04-18 09:09:29

    I found a way, set the following two properties, and then n it will take effect

    Label.lineBreakMode = NSLineBreakMode.ByWordWrapping
    Label.numberOfLines = 0
    
    label.text = "lineone\nlinetwo"

    reply
    0
  • PHP中文网

    PHP中文网2017-04-18 09:09:29

    Yes. But you have to set the numberoflines of UILabel

    reply
    0
  • Cancelreply