- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
UIView *view1 = [[UIView alloc] initWithFrame:CGRectMake(10, 50, 100, 50)];
view1.backgroundColor = [UIColor blueColor];
[self.view addSubview:view1];
UIView *view2 = [[UIView alloc] initWithFrame:CGRectMake(15, 55, 100, 50)];
view2.backgroundColor = [UIColor grayColor];
[self.view addSubview:view2];
//如果將下面兩行代碼都注釋掉? view1 會(huì)在下面? view2會(huì)在上面
//? 下面這行代碼能夠?qū)iew2? 調(diào)整到父視圖的最下面
//? ? [self.view sendSubviewToBack:view2];
//將view調(diào)整到父視圖的最上面
[self.view bringSubviewToFront:view1];
//插入層級(jí)
//- (void)insertSubview:(UIView *)view atIndex:(NSInteger)index;
}