macOS 开发新手并尝试创建一些非常基本的布局,但是我正在努力将 NSTextFields 添加到位于 NSScrollView 内的 NSStackView,到目前为止,我已经编写了以下内容,但它似乎将文本限制为单行,调整大小适合的窗户......
@IBOutlet weak var sv: NSStackView!
let lorem = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
sv.autoresizesSubviews = true
for i in 0..<10{
var test = NSTextField(string: lorem)
test.isEditable = false
test.isBordered = false
test.translatesAutoresizingMaskIntoConstraints = false
test.usesSingleLineMode = false
test.lineBreakMode = .byCharWrapping
test.wantsLayer = true
test.layer?.cornerRadius = 5
sv.addView(test, in: .top)
}}