【问题标题】:How to center elements in cellview in iCarousel?如何在 iCarousel 的 cellview 中居中元素?
【发布时间】: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]];

但它不起作用。有什么想法吗?

【问题讨论】:

    标签: ios icarousel


    【解决方案1】:

    试试这个:

    [self.backgroundView setCenter:CGPointMake(xcoord, ycoord)]; 
    

    这应该做的工作

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-01-23
      • 2014-09-19
      • 1970-01-01
      • 1970-01-01
      • 2022-08-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多