省钱达人

TYBaseAnimation.m 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. //
  2. // TYBaseAnimation.m
  3. // TYAlertControllerDemo
  4. //
  5. // Created by SunYong on 15/9/1.
  6. // Copyright (c) 2015年 tanyang. All rights reserved.
  7. //
  8. #import "TYBaseAnimation.h"
  9. @interface TYBaseAnimation ()
  10. @property (nonatomic, assign) BOOL isPresenting;
  11. @end
  12. @implementation TYBaseAnimation
  13. - (instancetype)initWithIsPresenting:(BOOL)isPresenting
  14. {
  15. if (self = [super init]) {
  16. self.isPresenting = isPresenting;
  17. }
  18. return self;
  19. }
  20. + (instancetype)alertAnimationIsPresenting:(BOOL)isPresenting
  21. {
  22. return [[self alloc]initWithIsPresenting:isPresenting];
  23. }
  24. + (instancetype)alertAnimationIsPresenting:(BOOL)isPresenting preferredStyle:(TYAlertControllerStyle)preferredStyle
  25. {
  26. return [[self alloc]initWithIsPresenting:isPresenting];
  27. }
  28. // override this moethod
  29. - (NSTimeInterval)transitionDuration:(id<UIViewControllerContextTransitioning>)transitionContext
  30. {
  31. return 0.4;
  32. }
  33. - (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext
  34. {
  35. if (_isPresenting) {
  36. [self presentAnimateTransition:transitionContext];
  37. }else {
  38. [self dismissAnimateTransition:transitionContext];
  39. }
  40. }
  41. - (void)presentAnimateTransition:(id<UIViewControllerContextTransitioning>)transitionContext
  42. {
  43. }
  44. - (void)dismissAnimateTransition:(id<UIViewControllerContextTransitioning>)transitionContext
  45. {
  46. }
  47. @end