WMZPageScroller.m 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. //
  2. // WMZPageScroller.m
  3. // WMZPageController
  4. //
  5. // Created by wmz on 2019/9/20.
  6. // Copyright © 2019 wmz. All rights reserved.
  7. //
  8. #import "WMZPageScroller.h"
  9. #import "WMZPageConfig.h"
  10. @implementation WMZPageScroller
  11. - (instancetype)initWithFrame:(CGRect)frame style:(UITableViewStyle)style{
  12. if (self = [super initWithFrame:frame style:style]) {
  13. self.showsHorizontalScrollIndicator = NO;
  14. self.scrollsToTop = NO;
  15. }
  16. return self;
  17. }
  18. - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
  19. CGFloat naVi = self.wFromNavi?PageVCNavBarHeight:0;
  20. CGFloat segmentViewContentScrollViewHeight = PageVCHeight - naVi - self.menuTitleHeight;
  21. CGPoint currentPoint = [gestureRecognizer locationInView:self];
  22. CGRect containRect = CGRectMake(0, self.contentSize.height - segmentViewContentScrollViewHeight, PageVCWidth, segmentViewContentScrollViewHeight);
  23. if (!self.canScroll) return NO;
  24. if (CGRectContainsPoint(containRect, currentPoint) ) {
  25. return YES;
  26. }
  27. return NO;
  28. }
  29. - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRequireFailureOfGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
  30. if ([NSStringFromClass(otherGestureRecognizer.view.class) isEqualToString:@"UITableViewWrapperView"] && [otherGestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]]) {
  31. return YES;
  32. }
  33. return NO;
  34. }
  35. @end
  36. @implementation UIImage(PageImageName)
  37. + (UIImage*)pageBundleImage:(NSString*)name{
  38. NSBundle *bundle = [NSBundle bundleWithPath:[[NSBundle bundleForClass:[WMZPageScroller class]] pathForResource:@"PageController" ofType:@"bundle"]];
  39. NSString *path = [bundle pathForResource:name ofType:@"png"];
  40. if (!path) {
  41. return [UIImage imageNamed:name];
  42. }else{
  43. return [UIImage imageWithContentsOfFile:path];
  44. }
  45. }
  46. @end