0
出於某種原因,這個VLF代碼..:如何使用VLF堆疊堆疊物體?
// Label Constraints
var allConstraints = [NSLayoutConstraint]()
let views = ["chapterVerseLabel" : chapterVerseLabel, "sanskritLabel" : sanskritLabel, "englishLabel" : englishLabel, "translationLabel" : translationLabel, "commentaryLabel" : commentaryLabel]
allConstraints += NSLayoutConstraint.constraintsWithVisualFormat("V:|-[chapterVerseLabel]-[sanskritLabel]-[englishLabel]-[translationLabel]-[commentaryLabel]-|", options: [], metrics: nil, views: views)
allConstraints += NSLayoutConstraint.constraintsWithVisualFormat("H:|-15-[chapterVerseLabel]-15-|", options: [], metrics: nil, views: views)
allConstraints += NSLayoutConstraint.constraintsWithVisualFormat("H:|-15-[sanskritLabel]-15-|", options: [], metrics: nil, views: views)
allConstraints += NSLayoutConstraint.constraintsWithVisualFormat("H:|-15-[englishLabel]-15-|", options: [], metrics: nil, views: views)
allConstraints += NSLayoutConstraint.constraintsWithVisualFormat("H:|-15-[translationLabel]-15-|", options: [], metrics: nil, views: views)
allConstraints += NSLayoutConstraint.constraintsWithVisualFormat("H:|-15-[commentaryLabel]-15-|", options: [], metrics: nil, views: views)
NSLayoutConstraint.activateConstraints(allConstraints)
是生產這樣的:
似乎我無法理解的是爲什麼有第一對象之間的巨大差距chapterVerseLabel
。理想情況下,我希望將對象堆疊在另一個之上。可能是10點之間的保證金。這是我認爲這條線會做的:
allConstraints += NSLayoutConstraint.constraintsWithVisualFormat("V:|-[chapterVerseLabel]-[sanskritLabel]-[englishLabel]-[translationLabel]-[commentaryLabel]-|", options: [], metrics: nil, views: views)
我試着通過增加指定的高度等變化,但似乎沒有工作。