How to add view in UIWindow?

前端 未结 8 1429
星月不相逢
星月不相逢 2021-02-14 22:42

I wanted to add a view in UIWindow with following code:

 AppDelegate *delegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
 UIWindo         


        
8条回答
  •  别那么骄傲
    2021-02-14 23:04

    If are you using UINavigationController Use:

    [self.navigationController.view.window addSubview:aView];
    

    If are you using UITabBarController Use:

    [self.tabBarController.view.window addSubview:aView];
    

    In AppDelegate you can directly assign a view to window. In appDelegate didFinishLaunchingWithOptions method Use:

    [self.window addSubview:aView];
    

    Hope it helps...

提交回复
热议问题