如何将变量合并到 NSLayoutConstraint 字符串中?
How do you incorporate a variable in a NSLayoutConstraint string?
是否有如下演示的在约束字符串中使用变量的正确方法?
let x = 6
self.addConstraints(
NSLayoutConstraint.constraintsWithVisualFormat(
"H:|-x-[subView(==16)]|",
options:[], metrics:nil,
views:viewDictionary))
self.addConstraints(
NSLayoutConstraint.constraintsWithVisualFormat(
"V:|-x-[subView(==16)]|",
options:[], metrics:nil,
views:viewDictionary))
这就是 metrics
词典的用途。传递像 [ "x": x ]
.
这样的字典
是否有如下演示的在约束字符串中使用变量的正确方法?
let x = 6
self.addConstraints(
NSLayoutConstraint.constraintsWithVisualFormat(
"H:|-x-[subView(==16)]|",
options:[], metrics:nil,
views:viewDictionary))
self.addConstraints(
NSLayoutConstraint.constraintsWithVisualFormat(
"V:|-x-[subView(==16)]|",
options:[], metrics:nil,
views:viewDictionary))
这就是 metrics
词典的用途。传递像 [ "x": x ]
.