UIViewController+Presentation.m 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. //
  2. // UIViewController+Presentation.m
  3. // HWPanModal
  4. //
  5. // Created by heath wang on 2019/4/29.
  6. //
  7. #import "UIViewController+Presentation.h"
  8. #import "UIViewController+LayoutHelper.h"
  9. #import "HWPanModalPresentationController.h"
  10. @interface UIViewController ()
  11. @end
  12. @implementation UIViewController (Presentation)
  13. - (void)hw_panModalTransitionTo:(PresentationState)state {
  14. if (!self.hw_presentedVC) return;
  15. [self.hw_presentedVC transitionToState:state animated:YES];
  16. }
  17. - (void)hw_panModalTransitionTo:(PresentationState)state animated:(BOOL)animated {
  18. if (!self.hw_presentedVC) return;
  19. [self.hw_presentedVC transitionToState:state animated:animated];
  20. }
  21. - (void)hw_panModalSetContentOffset:(CGPoint)offset animated:(BOOL)animated {
  22. if (!self.hw_presentedVC) return;
  23. [self.hw_presentedVC setScrollableContentOffset:offset animated:animated];
  24. }
  25. - (void)hw_panModalSetContentOffset:(CGPoint)offset {
  26. if (!self.hw_presentedVC) return;
  27. [self.hw_presentedVC setScrollableContentOffset:offset animated:YES];
  28. }
  29. - (void)hw_panModalSetNeedsLayoutUpdate {
  30. if (!self.hw_presentedVC) return;
  31. [self.hw_presentedVC setNeedsLayoutUpdate];
  32. }
  33. - (void)hw_panModalUpdateUserHitBehavior {
  34. if (!self.hw_presentedVC) return;
  35. [self.hw_presentedVC updateUserHitBehavior];
  36. }
  37. - (void)hw_dismissAnimated:(BOOL)animated completion:(void (^)(void))completion{
  38. if (!self.hw_presentedVC) return;
  39. [self.hw_presentedVC dismissAnimated:animated completion:completion];
  40. }
  41. - (HWDimmedView *)hw_dimmedView {
  42. return self.hw_presentedVC.backgroundView;
  43. }
  44. - (UIView *)hw_rootContainerView {
  45. return self.hw_presentedVC.containerView;
  46. }
  47. - (UIView *)hw_contentView {
  48. return self.hw_presentedVC.presentedView;
  49. }
  50. - (PresentationState)hw_presentationState {
  51. return self.hw_presentedVC.currentPresentationState;
  52. }
  53. @end