I am trying to set the text according to the size of the UILabel , and also to center. I do this programmatically. It looks like this:

As you can see, the text leaves the screen and is not centered.
This is my code:
let questions = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec ac faucibus tellus." questionsLabel = UILabel(frame: CGRectMake(10, 10, questionsView.frame.size.width - 20, 80)) questionsLabel.text = questions questionsLabel.font = UIFont(name: Font.FuturaMedium, size: 25) questionsLabel.sizeToFit() questionsLabel.numberOfLines = 0 questionsLabel.textAlignment = NSTextAlignment.Center questionsView.addSubview(questionsLabel)
What am I doing wrong?
uilabel swift uiview
Henry brown
source share