【发布时间】:2016-03-08 18:22:30
【问题描述】:
我正在尝试选择字符串并使用UILabels 在UIStackView 中显示它们,但我遇到了它们没有在我的应用程序中显示它们的文本的问题。我创建了以下游乐场:
import UIKit
import XCPlayground
let standardFrame = CGRect(x: 0, y: 0, width: 320, height: 480)
let stackView = UIStackView(frame: standardFrame)
stackView.backgroundColor = UIColor.blueColor()
let strings = ["Hello world", "Guten Tag", "Buenos Dias"]
strings.map { str in
let newLabel = UILabel()
newLabel.text = str
return newLabel
}.forEach(stackView.addArrangedSubview)
XCPlaygroundPage.currentPage.liveView = stackView
在助手视图中,我看到一个具有预期大小的黑框,而不是带有文本的蓝色框。
【问题讨论】:
标签: xcode uikit swift-playground uistackview