ios 自动布局水平跟垂直居中

[view addConstraint:[NSLayoutConstraint constraintWithItem:segment attribute:NSLayoutAttributeCenterX                     relatedBy:NSLayoutRelationEqual toItem:view attribute:NSLayoutAttributeCenterX multiplier:1.0f                       constant:00.0f]];

    [view addConstraint:[NSLayoutConstraint constraintWithItem:segment attribute:NSLayoutAttributeCenterY                     relatedBy:NSLayoutRelationEqual toItem:view attribute:NSLayoutAttributeCenterY multiplier:1.0f                       constant:00.0f]];

原文地址:https://www.cnblogs.com/Xujg/p/5586732.html