Reputation: 21
I have UITextView with 10 lines and now I'm trying to insert line break at the end of 5th line. How is it possible?
Upvotes: 0
Views: 348
Reputation: 675
here is :
let textview = UITextView()
textview.frame = CGRect(x: 100, y: 100, width: 200, height: 200)
textview.text = "djhgiruior seitii iuuiuy yyt yt tr dtre d grf hth yghj jh u hu khku yi hhhhh\nuiytuftftyftyfytf"
textview.backgroundColor = .green
self.view.addSubview(textview)
It will give new line after '\n'
. So use this
Upvotes: 0
Reputation: 285069
components(separatedBy: .newlines)
range(of:)
upperBound
index of the range.Upvotes: 3