我想在UIWindow中添加一个视图,其中包含以下代码:
AppDelegate *delegate = (AppDelegate *)[UIApplication sharedApplication].delegate; UIWindow *window = delegate.window; UIView *aView = [[UIView alloc]initWithFrame:CGRectMake(0,100,100)]; aView.backgroundColor = [UIColor blackColor]; [window addSubview:aView];
这段代码不起作用.我想克隆UIAlertView的属性.当我们打电话时,它会弹出一切
[alertViewInstance show];方法.
试过这个:
UIView *aView = [[UIView alloc]initWithFrame:CGRectMake(0,100)]; UIWindow* window = [UIApplication sharedApplication].keyWindow; if (!window) { window = [[UIApplication sharedApplication].windows objectAtIndex:0]; } [window addSubview:aView]; [window bringSubviewToFront:aView];