Update Xcode 5.1b5
Ctrl+click and drag from a view and release while the pointer is over the view. Select "Aspect Ratio". It will create a constraint where the first and second item is the view.
Before Xcode 5.1
You can't because the width/height editor lacks the fields to relate to another property or set the ratio:
Therefore, you can't express the following code in Interface Builder:
CGFloat ratio = 1.0;
NSLayoutConstraint *constraint = [NSLayoutConstraint
constraintWithItem:myView
attribute:NSLayoutAttributeWidth
relatedBy:NSLayoutRelationEqual
toItem:myView
attribute:NSLayoutAttributeHeight
multiplier:ratio
constant:0];
constraint.priority = 1000;
[myView.superview addConstraint:constraint];
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…