Has*_*jmi 3 animation objective-c ios uicollectionview uicollectionviewlayout
我有两个 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
Run Code Online (Sandbox Code Playgroud)
@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;
}
Run Code Online (Sandbox Code Playgroud)
当我选择一个单元格时,我想使用自定义动画更改 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];
}
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点?
只需包裹_collectionView.collectionViewFlowLayout = flowLayout一个UIView动画块。
[UIView animateWithDuration:5.0 delay:0.0 options:UIViewAnimationOptionCurveEaseIn animations:^{
self.collectionView.collectionViewLayout = flowLayout;
} completion:^(BOOL finished) {
if (finished) {
// Do Something
}
}];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6363 次 |
| 最近记录: |