Search code examples
iosobjective-cframecgrectintersectsrect

Using View Frame when inside.


I have an image view controlled by accelerometer and they are able to go out of the screen, how is it possible to detect if the image view is out of the screen and not visible to the user. I have tried using CGRectIntersectsRect and I also used self.view.frame but when my image view spawned it immediately detected it cause it was already in the view.


Solution

  • You need to use convertRect: toView: and CGRectIntersect which will return CGRect and then you can compare both using CGRectEqualToRect

    For sample you can follow this