how to add a view over window in uiviewcontroller

前端 未结 4 706
轮回少年
轮回少年 2021-01-24 20:19

Is it possible to add a subview over the window from a uiviewcontroller and then removing that also?

Thanks Pankaj

4条回答
  •  渐次进展
    2021-01-24 20:52

    You can use like this too.

    For adding:

    [[UIApplication sharedApplication].keyWindow.rootViewController addChildViewController:childVC];
    [[UIApplication sharedApplication].keyWindow.rootViewController.view addSubview:childVC.view];
    

    For removing:

    [childVC.view removeFromSuperview];
    [childVC removeFromParentViewController];
    

提交回复
热议问题