多行可编辑的文本片段:可编辑的UILabel?

我正在尝试创build一个可编辑文本的大图,但似乎有1个选项:使用一个小的UITextField。

我知道UILabels可以是大而宽,但我不知道如何使一个可编辑的UILabel。

我尝试了UILabel属性和.layer方法,但似乎没有任何工作。 有人build议我应该怎么做?

总之,我正在寻找一个多行可编辑的文本。

UITextView的胜利!

UITextViews允许对文本进行多行处理,如果使用UITextViewDelegate,它可以提供允许在单击textView时等特定事物的方法。

使用UITextView,您可以提供特定数量的行(如果您只需要3个,您可以指定它),并提供超链接(如果需要)。

这里是我有一个例子(改变了一点),以显示一个例子亚…

 let textBox:UITextView = UITextView(frame: CGRect(x: firstBox.frame.width*0, y: firstBox.frame.height*0.375, width: firstBox.frame.width*1, height: firstBox.frame.height*0.5)) textBox.backgroundColor = UIColor.clearColor() let websiteName = "http://stackoverflow.com/posts/38035564" textBox.text = "SO is an awesome coding site! Please visit\n\(websiteName)" //No need to set number of lines, it will auto set to as many as needed! textBox.editable = false textBox.selectable = true //Register the hyperlink textBox.dataDetectorTypes = UIDataDetectorTypes.All textBox.textColor = UIColor.grayColor() //Change only the hyperlink part let textRange = NSMakeRange(textBox.text.characters.count-websiteName.characters.count, websiteName.characters.count) let style = NSMutableParagraphStyle() style.alignment = NSTextAlignment.Center let attributedText = NSMutableAttributedString(string: textBox.text, attributes: [NSFontAttributeName:UIFont( name: (textBox.font?.fontName)!, size:13/15*fontSize)!, NSParagraphStyleAttributeName: style]) attributedText.addAttribute(NSUnderlineStyleAttributeName , value:NSUnderlineStyle.StyleSingle.rawValue, range: textRange) textBox.attributedText = attributedText firstBox.addSubview(textBox)