Label if self adjust with swift text size?

4

I have a label inside a scrollView, and this label gets a N texts, some are small and others great so the idea was to put in scrollView, plus the problem is that I can not adjust the label to increase as the text , it cuts the rest of the line. The scrollView is not large is just a small part of the screen.

I have tried this in the code, but it did not work

 @IBOutlet weak var svPergunta: UIScrollView!
@IBOutlet weak var lblPergunta: UILabel!

var sPergunta = String()

override func viewDidLoad() {
        super.viewDidLoad()

    lblPergunta.adjustsFontSizeToFitWidth = true
    lblPergunta.text = sPergunta
    lblPergunta.lineBreakMode = NSLineBreakMode.ByWordWrapping
    svPergunta.contentSize.height = 200

}
    
asked by anonymous 24.09.2015 / 00:16

1 answer

1

The alternative that I found for my problem and in the case much better than the Label was to use TextView so I deleted the ScrollView also using only one component on the screen.

import UIKit

class ViewPerguntas: UIViewController {


@IBOutlet weak var lblPergunta: UITextView!

var sPergunta = String()

override func viewDidLoad() {
        super.viewDidLoad()

    lblPergunta.text = sPergunta
    lblPergunta.editable = false
    lblPergunta.selectable = false

   }

}
    
24.09.2015 / 06:57