How to add view in UIWindow?

前端 未结 8 1423
星月不相逢
星月不相逢 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:20

    You can try below code...for adding subview to window

    UIView *aView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 100, 100)];
    aView.backgroundColor = [UIColor blackColor];
    [[UIApplication sharedApplication].keyWindow addSubview:aView];
    

    //Removing

    [aView removeFromSuperview];
    

    Hope it helps you..!

提交回复
热议问题