去掉UICollectionView 在 reloadItems时默认附加的隐式fade动画。

来源:互联网 发布:梦想海贼王超进化数据 编辑:程序博客网 时间:2024/05/16 15:04
//方法一[UIView performWithoutAnimation:^{    [collectionView reloadItemsAtIndexPaths:@[[NSIndexPath indexPathForItem:index inSection:0]]];}];
//方法二[UIView animateWithDuration:0 animations:^{    [collectionView performBatchUpdates:^{        [collectionView reloadItemsAtIndexPaths:@[[NSIndexPath indexPathForItem:index inSection:0]]];    } completion:nil];}];

如果你的APP只支持iOS7+ 推荐使用第一种方式performWithoutAnimation

上述情况多用于自定义控件使用了layer.mask的情况 如果有这种情况 上面提到的方法是无法取消CALayer的动画的 但是解决办法也很简单


- (void)layoutSubviews{    [super layoutSubviews];    [CATransaction begin];    [CATransaction setDisableActions:YES];    self.frameLayer.frame = self.frameView.bounds;    [CATransaction commit];}

0 0
原创粉丝点击