我有一个简单的约束,我更愿意使用受 Asci-art 启发的格式来指定它,但是我似乎找不到这样的例子。
NSLayoutConstraint *centerXConstraint = [NSLayoutConstraint constraintWithItem: childView
attribute:NSLayoutAttributeCenterX
relatedBy:NSLayoutRelationEqual
toItem: parentView
attribute:NSLayoutAttributeCenterX
multiplier:1.0f
constant:0.0f]
我尝试了一些东西,例如'|-[childView]-|' 但这只会迫使它在其父级左侧的 X 点。