【发布时间】:2015-03-25 20:20:28
【问题描述】:
我正在尝试将文本设置为适合 UILabel 的大小并居中。我正在以编程方式执行此操作。这是目前的样子:
如您所见,文本离开了屏幕,也没有居中。
这是我的代码:
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)
我做错了什么?
【问题讨论】: