iOS 動畫:YSLTransitionAnimator
YSLTransitionAnimator 是一個 Pinterest 風格的過渡動畫。
用法
- importYSLTransitionAnimator.h
- importUIViewController+YSLTransition.h
Push Transition
@interface ViewController () <YSLTransitionAnimatorDataSource> - (void)viewWillDisappear:(BOOL)animated { [self ysl_removeTransitionDelegate]; } - (void)viewDidAppear:(BOOL)animated { float statusHeight = [[UIApplication sharedApplication] statusBarFrame].size.height; float navigationHeight = self.navigationController.navigationBar.frame.size.height; [self ysl_addTransitionDelegate:self]; [self ysl_pushTransitionAnimationWithToViewControllerImagePointY:statusHeight + navigationHeight animationDuration:0.3]; } #pragma mark -- YSLTransitionAnimatorDataSource - (UIImageView *)pushTransitionImageView { CollectionCell *cell = (CollectionCell *)[self.collectionView cellForItemAtIndexPath:[[self.collectionView indexPathsForSelectedItems] firstObject]]; return cell.itemImage; } - (UIImageView *)popTransitionImageView { return nil; }
Pop Transition
@interface ViewController () <YSLTransitionAnimatorDataSource> - (void)viewWillDisappear:(BOOL)animated { [self ysl_removeTransitionDelegate]; } - (void)viewDidAppear:(BOOL)animated { float statusHeight = [[UIApplication sharedApplication] statusBarFrame].size.height; float navigationHeight = self.navigationController.navigationBar.frame.size.height; [self ysl_addTransitionDelegate:self]; [self ysl_popTransitionAnimationWithCurrentScrollView:self.tableView cancelAnimationPointY:self.headerImageView.frame.size.height - (statusHeight + navigationHeight) animationDuration:0.3 isInteractiveTransition:YES]; } #pragma mark -- YSLTransitionAnimatorDataSource - (UIImageView *)pushTransitionImageView { return nil; } - (UIImageView *)popTransitionImageView { return self.headerImageView; }
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!