我想通过JSON
字符串从服务器获取我的图层布局信息。并且布局信息与NSLayoutConstraint
的结构相同。
[
{
"secondItem": "1", // id of second item, can be use to find the related layer, the first item is a existed layer
"firstAttribute": "left", // same as NSLayoutConstraint.Attribute
"secondAttribute": "left",
"relation": "equal", // same as NSLayoutRelation
"multiplier": "1",
"constant": "10"
},
{
"secondItem": "1",
"firstAttribute": "right",
"secondAttribute": "right",
"relation": "equal",
"multiplier": "1",
"constant": "10"
},
{
"secondItem": "1",
"firstAttribute": "top",
"secondAttribute": "top",
"relation": "equal",
"multiplier": "1",
"constant": "10"
},
{
"secondItem": "1",
"firstAttribute": "bottom",
"secondAttribute": "bottom",
"relation": "equal",
"multiplier": "1",
"constant": "10"
}
]
这些JSON
仅用于描述CALayer
的布局信息,而不是直接应用于UIView
。
但是如何说明NSLayoutConstraint
至CALayer
的边界和位置属性?
谢谢!