Swift 中添加的UIView都是有层级的。
我们先添加三个看一看
- let view1=UIView(frame: CGRectMake(10, 50, 200, 200))  
- let view2=UIView(frame: CGRectMake(60, 100, 200, 200))  
- let view3=UIView(frame: CGRectMake(110, 150, 200, 200))  
- view1.backgroundColor=UIColor.redColor()  
- view2.backgroundColor=UIColor.greenColor()  
- view3.backgroundColor=UIColor.blueColor()  
- self.view.addSubview(view1)  
- self.view.addSubview(view2)  
- self.view.addSubview(view3)  
 
效果如下

我们可以看到他们的层次是按照添加顺序走的
那么我们尝试调整一下他的层次
- self.view.bringSubviewToFront(view1)  
-   
- self.view.sendSubviewToBack(view1)  
-   
- self.view.exchangeSubviewAtIndex(2, withSubviewAtIndex: 3)  
 
我们尝试一下以上三个方法就明白他们的意思了
苹果开发群 :414319235  欢迎加入  欢迎讨论问题
Swift UIView 层次调整
原文:http://www.cnblogs.com/Free-Thinker/p/6478037.html