Meta interview question

How would you implement UIView hitTest mehtod?

Interview Answers

Anonymous

9 Dec 2018

UIView * hitTest(UIView *view, CGPoint point, UIEvent *event) { if (view == nil) return nil; if (CGRectContainsPoint(view.bounds, point)) return view; else hitTest(view.superView, point, event); }

1

Anonymous

17 Feb 2018

Thanks for sharing your experience and much appreciated. It would be really great if could post remaining questions as well to help others to fulfil their dream job.

Anonymous

9 Dec 2018

UIView * hitTest(UIView *view, CGPoint point, UIEvent *event) { if (CGRectContainsPoint(view.bounds, point); return view; for (UIView *view in view.subViews) { hitTest(view, point, event); } }

1