美文网首页
iOS oc-调整view层级

iOS oc-调整view层级

作者: 青菜白玉堂 | 来源:发表于2017-06-21 17:55 被阅读67次

    - (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 会在下面  view2会在上面

    //  下面这行代码能够将view2  调整到父视图的最下面

    //    [self.view sendSubviewToBack:view2];

    //将view调整到父视图的最上面

    [self.view bringSubviewToFront:view1];

    //插入层级

    //- (void)insertSubview:(UIView *)view atIndex:(NSInteger)index;

    }

    相关文章

      网友评论

          本文标题:iOS oc-调整view层级

          本文链接:https://www.haomeiwen.com/subject/cjutcxtx.html