Alternative way to check intersect scrollview subview frame Swift

213 views Asked by At

Currently i'm following the below code to check the two CGRect Frame intersects.

Code:-

var visibleRect = CGRect.init(x: 0, y: 0, width: 0, height: 0)
visibleRect.origin =   scrollView.contentOffset
visibleRect.size   =   scrollView.bounds.size

if !visibleRect.intersects(ImagView.frame) { 
     print("Outer View")
}else{
     print("Inner View")     
}

This code works When ImagView frame goes totally out of visibleRect. But we need when imageview frame origin close to scrollview frame origin. More detail Please check the screen shot.

Second Screenshot

When the car move out from the screen the above code working perfectly. But we need when car near to close out from the scrollview frame.

Question: Can someone please explain to me how to get near to close out?

Any help would be greatly appreciated.

Thanks in advance.

0

There are 0 answers