I have UIViewone defined in a .xib file. I need to install translatesAutoresizingMaskIntoConstraints = NO. This means that the frame does not translate into restrictions, so I need to set the size limits myself.
I created a working category method for UIView:
-(NSArray*)setSizeConstraints:(CGSize)size
{
NSLayoutConstraint* height = [NSLayoutConstraint constraintWithItem:self attribute:NSLayoutAttributeHeight relatedBy:0 toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1 constant:size.height];
NSLayoutConstraint* width = [NSLayoutConstraint constraintWithItem:self attribute:NSLayoutAttributeWidth relatedBy:0 toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1 constant:size.width];
[self addConstraint:height];
[self addConstraint:width];
return [NSArray arrayWithObjects:height, width, nil];
}
But I would like to set these restrictions from the Xcode interface constructor, but all of my AutoLayout controls are grayed out:

Is there a way to do this in an interface builder?
source
share