NSString with \n or line break

前端 未结 10 826
生来不讨喜
生来不讨喜 2020-12-04 11:15

Does anyone know how to use line breaks in NSString? I need to do something like this -

[NSString stringWithFormat:@\"%@,\\n%@\", mystring1,mystring2];
         


        
10条回答
  •  南方客
    南方客 (楼主)
    2020-12-04 11:53

    In Swift 3, its much simpler

    let stringA = "Terms and Conditions"
    let stringB = "Please read the instructions"
    
    yourlabel.text =  "\(stringA)\n\(stringB)"
    

    or if you are using a textView

    yourtextView.text =  "\(stringA)\n\(stringB)"
    

提交回复
热议问题