【发布时间】:2015-01-19 04:09:07
【问题描述】:
AutoLayoutbyExample via Apple Developer Documentation
任何人都有一个如何创建间隔视图以在 VFL 中将标签之间的间距设置为相等的示例?
labelsDictionary = [ "label1": label1,
"label2": label2,
"label3": label3,
"label4": label4 ]
let metrics = ["edgeSpacing": 20, "spacingBetween": 5, "labelWidth": 50]
let constraints = "H:|-(==edgeSpacing)-[label1(==labelWidth@999)]-[label2(==label1)]-[label3(==label1)]-[label3(==label1)]-[label4(==label1)]-(==edgeSpacing)-|"
self.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat( format : constraints,
options : .allZeros,
metrics : metrics,
views : labelsDictionary))
我只是想知道如何在 Swift 中创建间隔,以确保标签之间的宽度始终相等但优先级最低。
【问题讨论】:
标签: ios objective-c swift autolayout visual-format-language