【发布时间】:2014-01-27 20:46:13
【问题描述】:
我想在 iCarousel 视图中居中放置三个 UI 元素(一个按钮和两个文本标签)。我试过像这样使用 NSLayoutContraits:
[self.backgroundView addConstraint:[NSLayoutConstraint constraintWithItem:self.descriptionLabel
attribute:NSLayoutAttributeCenterX
relatedBy:NSLayoutRelationEqual
toItem:self.backgroundView
attribute:NSLayoutAttributeCenterX
multiplier:1
constant:0]];
[self.backgroundView addConstraint:[NSLayoutConstraint constraintWithItem:self.descriptionLabel
attribute:NSLayoutAttributeCenterY
relatedBy:NSLayoutRelationEqual
toItem:self.backgroundView
attribute:NSLayoutAttributeCenterY
multiplier:1
constant:0]];
但它不起作用。有什么想法吗?
【问题讨论】: