HWPanModalHeight.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. //
  2. // HWPanModalHeight.h
  3. // Pods
  4. //
  5. // Created by heath wang on 2019/4/26.
  6. //
  7. #import <UIKit/UIKit.h>
  8. #import <Foundation/Foundation.h>
  9. typedef NS_ENUM(NSInteger, PanModalHeightType) {
  10. PanModalHeightTypeMax NS_SWIFT_NAME(max), // from top max
  11. PanModalHeightTypeMaxTopInset NS_SWIFT_NAME(topInset), // from top offset
  12. PanModalHeightTypeContent NS_SWIFT_NAME(content), // from bottom
  13. PanModalHeightTypeContentIgnoringSafeArea NS_SWIFT_NAME(contentIgnoringSafeArea), // from bottom ignore safeArea
  14. PanModalHeightTypeIntrinsic NS_SWIFT_NAME(intrinsic), // auto get size, There is something wrong, DO NOT recommend to use.
  15. };
  16. struct PanModalHeight {
  17. PanModalHeightType heightType NS_SWIFT_NAME(type);
  18. CGFloat height;
  19. };
  20. typedef struct PanModalHeight PanModalHeight;
  21. /**
  22. * When heightType is PanModalHeightTypeMax, PanModalHeightTypeIntrinsic, the height value will be ignored.
  23. */
  24. CG_INLINE PanModalHeight PanModalHeightMake(PanModalHeightType heightType, CGFloat height) {
  25. PanModalHeight modalHeight;
  26. modalHeight.heightType = heightType;
  27. modalHeight.height = height;
  28. return modalHeight;
  29. }
  30. static inline BOOL HW_FLOAT_IS_ZERO(CGFloat value) {
  31. return (value > -FLT_EPSILON) && (value < FLT_EPSILON);
  32. }
  33. static inline BOOL HW_TWO_FLOAT_IS_EQUAL(CGFloat x, CGFloat y) {
  34. CGFloat minusValue = fabs(x - y);
  35. CGFloat criticalValue = 0.0001;
  36. if (minusValue < criticalValue || minusValue < FLT_MIN) {
  37. return YES;
  38. }
  39. return NO;
  40. }