當我在Xcode 7中編輯我的約束時,我在Interface Builder中發現標識符字段。如何使用約束,約束的標識符是什麼?使用標識符可以以編程方式訪問約束並更改常量?我的問題是爲什麼這個標識符有幫助?如何在自動佈局中使用約束標識符以及如何使用標識符更改約束? [Swift]
有什麼方法與在子視圖循環,再次循環約束子視圖的標識符來訪問約束。我的意思是有什麼方法可以直接訪問約束而不需要循環。
UPDATE
我tryed這個代碼,但只有寬度和高度約束被訪問
for subview in view.subviews {
for constraint in subview.constraints() {
if constraint.identifier == "identifier" {
return constraint
}
}
}
在這裏回答:http://stackoverflow.com/questions/27791597/is-there-a-way-to-add-an-identifier-to-auto-layout-constraints-in-interface-buil/31831576# 31831576 – oyalhi
http://stackoverflow.com/questions/33038451/get-reference-to-nslayoutconstraint-using-identifier-set-in-storyboard –
@oyalhi我更新了問題.. –