material_timing.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // Copyright 2016 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef IOS_CHROME_COMMON_MATERIAL_TIMING_H_
  5. #define IOS_CHROME_COMMON_MATERIAL_TIMING_H_
  6. #import <CoreGraphics/CoreGraphics.h>
  7. #import <QuartzCore/QuartzCore.h>
  8. #import <UIKit/UIKit.h>
  9. namespace ios {
  10. namespace material {
  11. extern const CGFloat kDuration0;
  12. extern const CGFloat kDuration1;
  13. extern const CGFloat kDuration2;
  14. extern const CGFloat kDuration3;
  15. extern const CGFloat kDuration4;
  16. extern const CGFloat kDuration5;
  17. extern const CGFloat kDuration6;
  18. extern const CGFloat kDuration7;
  19. extern const CGFloat kDuration8;
  20. // Type of material timing curve.
  21. typedef NS_ENUM(NSUInteger, Curve) {
  22. CurveEaseInOut,
  23. CurveEaseOut,
  24. CurveEaseIn,
  25. CurveLinear,
  26. };
  27. // Per material spec, a motion curve with "follow through".
  28. CAMediaTimingFunction* TransformCurve2();
  29. // Returns a timing function related to the given |curve|.
  30. CAMediaTimingFunction* TimingFunction(Curve curve);
  31. } // material
  32. } // ios
  33. @interface UIView (CrMaterialAnimations)
  34. // Performs a standard UIView animation using a material timing |curve|.
  35. // Note: any curve option specified in |options| will be ignored in favor of the
  36. // specified curve value.
  37. // See also: +[UIView animateWithDuration:delay:animations:completion].
  38. + (void)cr_animateWithDuration:(NSTimeInterval)duration
  39. delay:(NSTimeInterval)delay
  40. curve:(ios::material::Curve)curve
  41. options:(UIViewAnimationOptions)options
  42. animations:(void (^)(void))animations
  43. completion:(void (^)(BOOL finished))completion;
  44. @end
  45. #endif // IOS_CHROME_COMMON_MATERIAL_TIMING_H_