我有两个collectionViewLayout,分别是verticalFlowLayout和fullScreenHorizontalFlowLayout。
@implementation VerticalFlowLayout
- (instancetype)init
{
if (self = [super init]) {
self.sectionInset = UIEdgeInsetsMake(12, 0, 0, 0);
self.minimumLineSpacing = 10;
self.minimumInteritemSpacing = 0;
self.itemSize = CGSizeMake(CGRectGetWidth([UIScreen mainScreen].bounds), 244);
}
return self;
}
@end
@implementation FullScreenFlowLayout
- (instancetype)init
{
if (self = [super init]) {
self.sectionInset = UIEdgeInsetsMake(0, 0, 0, 0);
self.minimumLineSpacing = 10;
self.minimumInteritemSpacing = 0;
self.itemSize = CGSizeMake(CGRectGetWidth([UIScreen mainScreen].bounds), CGRectGetHeight([UIScreen mainScreen].bounds));
self.scrollDirection = UICollectionViewScrollDirectionHorizontal;
}
return self;
}
当我选择一个单元格时,我想通过自定义动画更改collectionView布局。默认动画是线性动画,持续时间为0.33。
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
if ([_collectionView.collectionViewLayout isKindOfClass:[FullScreenFlowLayout class]]) {
VerticalFlowLayout *flowLayout = [VerticalFlowLayout new];
[_collectionView setCollectionViewLayout:flowLayout animated:YES completion:^(BOOL finished) {
}];
}
else
[_collectionView setCollectionViewLayout:[FullScreenFlowLayout new] animated:YES];
}
我该如何做到这一点?