Adding multiple Lines of text into UILabel in swift
Hi I want to display some text in my UILabel line by line when an action is occurred
Hi, I have a textbox, button and a UILabel, lets say I've typed in "This text will be displayed line by line in a UILabel" and pressed the button to display the text in the UILabel..
so inside the UILabel it will look like:
This
text
will
be
displayed
line
by
line
in
a
UILabel
....
I've been searching forums but could not found an answer.. so I don't know if this is possible.. please help ps I've set number of lines to 0 and line breaks is set to word wrap
let label = UILabel(frame: CGRect(x: 100, y: 100, width: 100, height: 300)) // make the height biggest
// label.lineBreakMode = NSLineBreakMode.ByWordWrapping
// label.numberOfLines = 0
dont work if label width bigger word width
var string = "This text will be displayed line by line in a UILabel"
var array = string.componentsSeparatedByString(" ")
var newstring = join("r", array)
label.text = newstring
let labelText = "Writerthertextrwithrlinerbreaks."
Does it have to be a UILabel? You could use UITextField instead which has some advantageous handling options
链接地址: http://www.djcxy.com/p/28236.html上一篇: 无法更改UILabel文字颜色