解决方法
您将检查superview(在控件中,在您的案例中为self.view)
subviews
属性中的视图顺序.
superview子视图中索引0处的视图是最后面的视图,然后索引1处的视图将位于其顶部,索引2处的视图将位于索引处的视图顶部等
(基本上视图位于视图之上,索引与其自己的索引相比较小)
NSInteger indexOfControl1 = [[self.view subviews] indexOfObject:control1]; NSInteger indexOfControl2 = [[self.view subviews] indexOfObject:control2]; if (indexOfControl1 > indexOfControl2) { //control1 is on top of control2 }