Detect if a UILabel hide another UILabel on same UIView
I'm developing an iPhone application.
I have a UIView used to augmented reality. I add some UILabel to that UIView dynamically and I want to know if there is a way to know when a UILabel hide another UILabel added on same UIView.
In other words: I'm adding UILabels at the middle of the screen (y position is always the same, x can vary). When I'm going to add another UILabel, I want to know if there is another UILabel at the same position.
Note: A UILabel will have a (x,y) origin position and a height and a width.
开发者_运维技巧Maybe there is a method to know where are "located" subview from a UIView.
Thanks.
If you do not apply any transforms to your views you can use CGRectIntersectsRect
functions to views' frames:
if (CGRectIntersectsRect(label1.frame, label2.frame){
// Intersect
}
精彩评论