Я обнаружил, что вы можете установить одно ограничение, которое центрирует вид, а затем ограничение с более высоким приоритетом, который гласит, что верхняя часть содержимого может быть больше 0.
// If the content is smaller than the scrollview then center it, else lock to top
NSLayoutConstraint *centerYConstraint = [NSLayoutConstraint constraintWithItem:self.contentController.view
attribute:NSLayoutAttributeCenterY
relatedBy:NSLayoutRelationEqual
toItem:_scrollView
attribute:NSLayoutAttributeCenterY
multiplier:1 constant:0];
// Constrain the top to not be smaller than 0 (multiplier:0)
NSLayoutConstraint *lockToTopConstraint = [NSLayoutConstraint constraintWithItem:self.contentController.view
attribute:NSLayoutAttributeTop
relatedBy:NSLayoutRelationGreaterThanOrEqual
toItem:_scrollView
attribute:NSLayoutAttributeTop
multiplier:0 constant:0];
//It't more important that the content doesn't go over the top than that it is centered
centerYConstraint.priority = UILayoutPriorityDefaultLow;
lockToTopConstraint.priority = UILayoutPriorityDefaultHigh;
[self.view addConstraints:@[centerYConstraint, lockToTopConstraint]];
Спасибо, это полезно! – Voxar