Currently there is a scrollview (whole screen) that sits behind a uiview (bottom portion of the screen). I"m trying to check whether or not a label on the scroll is covered by the uiview (this happens with iphone se). Is there a way to check if the uiview is covering the label on the scrollview? I tried using the center cgpoint of a label on the scrollview to see if its smaller than a point on the uiview but it won't allow me to compare two cgpoints for size:
if atmLabel.center < CGPoint(x: 156, y: 570) {
buttonView.dropShadow(shadowOpacity: 0.5)
}
For point checking, you should use
contains function of CGRect... in short this should work
let view = UIView()
let label = UILabel()
if label.frame.contains(view.frame) {
//Do your stuff...
}
You can use the view hiearchy with Xcode with this button
Or you can simply print out on the current viewController subviews
print(self.view.subviews)
this prints out array of UIView subclasses sorted by ascending order of layer on the view... I recommend the first way of debugging :)
If you want to see if two views overlap in code, I think this should work:
if view1.frame.intersects(view2.frame) {
// handle overlap
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With