猎豆优选

TYAlertController+TransitionAnimate.m 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. //
  2. // TYAlertController+TransitionAnimate.m
  3. // TYAlertControllerDemo
  4. //
  5. // Created by tanyang on 15/9/1.
  6. // Copyright (c) 2015年 tanyang. All rights reserved.
  7. //
  8. #import "TYAlertController.h"
  9. #import "TYAlertFadeAnimation.h"
  10. #import "TYAlertScaleFadeAnimation.h"
  11. #import "TYAlertDropDownAnimation.h"
  12. @implementation TYAlertController (TransitionAnimate)
  13. #pragma mark - UIViewControllerTransitioningDelegate
  14. - (id<UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented presentingController:(UIViewController *)presenting sourceController:(UIViewController *)source
  15. {
  16. switch (self.transitionAnimation) {
  17. case TYAlertTransitionAnimationFade:
  18. return [TYAlertFadeAnimation alertAnimationIsPresenting:YES];
  19. case TYAlertTransitionAnimationScaleFade:
  20. return [TYAlertScaleFadeAnimation alertAnimationIsPresenting:YES];
  21. case TYAlertTransitionAnimationDropDown:
  22. return [TYAlertDropDownAnimation alertAnimationIsPresenting:YES];
  23. case TYAlertTransitionAnimationCustom:
  24. return [self.transitionAnimationClass alertAnimationIsPresenting:YES preferredStyle:self.preferredStyle];
  25. default:
  26. return nil;
  27. }
  28. }
  29. - (id<UIViewControllerAnimatedTransitioning>)animationControllerForDismissedController:(UIViewController *)dismissed
  30. {
  31. switch (self.transitionAnimation) {
  32. case TYAlertTransitionAnimationFade:
  33. return [TYAlertFadeAnimation alertAnimationIsPresenting:NO];
  34. case TYAlertTransitionAnimationScaleFade:
  35. return [TYAlertScaleFadeAnimation alertAnimationIsPresenting:NO];
  36. case TYAlertTransitionAnimationDropDown:
  37. return [TYAlertDropDownAnimation alertAnimationIsPresenting:NO];
  38. case TYAlertTransitionAnimationCustom:
  39. return [self.transitionAnimationClass alertAnimationIsPresenting:NO preferredStyle:self.preferredStyle];
  40. default:
  41. return nil;
  42. }
  43. }
  44. @end