Check if the CGPoint is inside the given view?

As the question itself explains, how to check if a given point is inside a given view frame.

+3


source to share


2 answers


You can achieve this in a variety of ways.



  • UIView

    pointInside

    ... It returns a boolean indicating whether the receiver contains the specified point.

    -(BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event

  • CGGeometry

    CGRectContainsPoint

    ... It returns whether the rectangle contains the specified point.

    bool CGRectContainsPoint (CGRect rect, CGPoint point);

  • CGGeometry

    CGPointEqualToPoint

    method.It whether two points return equal.

    bool CGPointEqualToPoint (CGPoint point1, CGPoint point2);

+12


source


CGRectContainsPoint(view.frame, point);

      



Link: CGRectContainsPoint

+8


source







All Articles