【问题标题】:Animate UICollectionView items on constraint change in custom layout自定义布局中约束更改的动画 UICollectionView 项目
【发布时间】:2015-02-13 20:44:33
【问题描述】:

我正在使用自定义 UICollectionview 布局,以圆形显示项目。在向上滑动时,我重置了我的 collectionview 上的约束并为这些约束更改设置动画。我希望我的项目随着约束的变化而动画化,所以这是一种流畅的体验。

我让它们制作动画,但只有在约束更改之后(我认为),它看起来又乱又奇怪,请在此处查看截屏视频:http://cl.ly/ZmA0

这是滑动手势方法中的代码:


- (void)foo:(UISwipeGestureRecognizer *)gesture {
    [self.view layoutIfNeeded];

    [self.collectionView mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.width.equalTo(self.view.mas_width);
        make.height.equalTo(self.collectionView.mas_width);
        make.top.equalTo(self.view.mas_top).offset(50);
    }];

    [UIView animateWithDuration:1.0 animations:^{
        [self.view layoutIfNeeded];
    }];

    [self.collectionView performBatchUpdates:^{
        CircleLayout *layout = (CircleLayout *)self.collectionView.collectionViewLayout;
    } completion:nil];
}

有什么建议吗?

【问题讨论】:

    标签: ios objective-c animation uicollectionview


    【解决方案1】:

    我不确定 MASConstraintMaker 是什么(并且视频无法播放)。 但是在 performBatchUpdates 块中,您将获得集合视图布局。你在用它做什么?它未使用。也许这可以为您指明正确的解决方案。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-01-31
      • 1970-01-01
      • 2014-05-26
      • 2012-10-11
      • 2014-01-27
      • 1970-01-01
      • 1970-01-01
      • 2018-11-12
      相关资源
      最近更新 更多