Of course, you can put them in a UIView and that the left edge of the view will be CenterX, and so they will be aligned in the middle. Or you can simply align the top header cell with CenterX and have the leading edge of each match. There are many ways that you can achieve what you ask for here.
NSLayoutContraint *constraint = [NSLayoutConstraint constraintWithItem:label attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeCenterX multiplier:1.0f constant:0.0f]; [self.view addConstraint:constraint]; NSArray *constraints [NSLayoutConstraint constraintsWithVisualFormat:@"V:|[label1]-(5)-[label2]-(5)-[label3]|" options:NSLayoutFormatAlignAllLeading metrics:nil views:@{ @"label1" : label1, @"label2" : label2, @"label3" : label3 }]; [self.view addConstraints:constraints];
The above are just examples of how you could do this in code, if you want, self.view is a view, but if you want a view of the contents of a UITableViewCell you could just switch to it.
source share