Próbuję ustawić tekst, aby dopasować rozmiar do UILabel
, a także być wyśrodkowany. Robię to programowo. Jest to, jak wygląda obecnie:Ustawianie tekstu w celu dopasowania do rozmiaru UILabel i środka w SWIFT
Jak widać, tekst będzie poza ekran i nie jest również centrum.
To jest mój kod:
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)
Co robię źle?