我想证明我的UILabel
文本,但它不起作用。我UIView
的NSTextAlignment.Josetified for UILabel does not work
声明:
descriptionUIView = UIView(frame: CGRect(x: 0, y: 0, width: self.view.frame.width, height: self.view.frame.height)
我UILabel
宣言:
bottleDescriptionLabel = UILabel(frame: CGRect(x: widthMargin, y: bottleDescriptionTitleLabel.frame.maxY + heightMargin, width: self.view.frame.width - (2 * widthMargin), height: heightBottleDescription - (2 * heightMargin)))
bottleDescriptionLabel.font = UIFont(name: "AvenirNext-Regular", size: 16)
bottleDescriptionLabel.text = bottleDescriptionString
bottleDescriptionLabel.lineBreakMode = NSLineBreakMode.ByWordWrapping
bottleDescriptionLabel.textAlignment = NSTextAlignment.Justified
bottleDescriptionLabel.numberOfLines = 0
它看起来是这样的:
,我不知道还有什么使用NSTextAlignment.Justified
来证明我的文本。我应该使用UITextView
吗?
谢谢!我更喜欢保留一个UILabel,所以我不必处理“文本选择”,“滚动”等。因此,您的解决方案非常好,谢谢。 – magohamoth 2014-11-21 12:02:50
仅供参考:从iOS 10开始,这不再是必需的,似乎'UILabel'已被固定为使用'NSTextAlignment.Justified' – kambala 2018-01-11 20:28:45