MBContentView.m 1018 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. //
  2. // MBContentView.m
  3. // LNManager
  4. //
  5. // Created by EchoShacolee on 2017/5/3.
  6. // Copyright © 2017年 lee. All rights reserved.
  7. //
  8. #import "MBContentView.h"
  9. @implementation MBContentView
  10. -(UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
  11. {
  12. UIView *view = [super hitTest:point withEvent:event];
  13. if (view == nil) {
  14. for (UIView *subView in self.subviews) {
  15. CGPoint myPoint = [subView convertPoint:point fromView:self];
  16. if (CGRectContainsPoint(subView.bounds, myPoint)) {
  17. for (UIButton * button in subView.subviews) {
  18. CGPoint myPoint2 = [button convertPoint:myPoint fromView:subView];
  19. if (CGRectContainsPoint(button.bounds, myPoint2)) {
  20. return button;
  21. }
  22. }
  23. }
  24. }
  25. }
  26. //打开的话 点击按键周围有效
  27. // if (view == self) {
  28. // return self.superview.subviews[0];
  29. // }
  30. return view;
  31. }
  32. @end