現在の blueView はそのスーパービューを理解していないため、xib 自体に制約を設定することはできず、コードで行う必要があると考えるのは正しいと確信しています。
コードでそれを行うには、redView が上の図の赤いビューへの Iboutlet であると仮定します。
nib を使用して blueView を作成しますが、translatesAutoresizingMaskIntoConstraints が no に等しいことを確認してください。
CustomView *blueView = [CustonView alloc] init]; // or what not
// atached the xib, should really be done in init of CustomView
NSArray *subviewArray = [[NSBundle mainBundle] loadNibNamed:@"myXib" owner:self options:nil];
UIView *mainView = [subviewArray objectAtIndex:0];
[blueView addSubview:mainView];
blueView.translatesAutoresizingMaskIntoConstraints = NO;
[self.redview addSubview:blueView]
制約を追加します。
[self.redView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"|[blueView]|" options:0 metrics:nil views:@{@"blueView":blueView}]];
[self.redView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[blueView]|" options:0 metrics:nil views:@{@"blueView":blueView}]];
ブーレンジャー