我想添加一个视图UIWindow
与以下代码:
AppDelegate *delegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
UIWindow *window = delegate.window;
UIView *aView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 100, 100)];
aView.backgroundColor = [UIColor blackColor];
[window addSubview:aView];
这段代码不起作用。我想克隆 UIAlertView 的属性。当我们调用时它会弹出在所有内容之上[alertViewInstance show];
method.
也尝试过这个:
UIView *aView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 100, 100)];
UIWindow* window = [UIApplication sharedApplication].keyWindow;
if (!window) {
window = [[UIApplication sharedApplication].windows objectAtIndex:0];
}
[window addSubview:aView];
[window bringSubviewToFront:aView];
如果您正在使用UINavigationController
Use:
[self.navigationController.view.window addSubview:aView];
如果您正在使用UITabBarController
Use:
[self.tabBarController.view.window addSubview:aView];
In AppDelegate
您可以直接将视图分配给窗口。在appDelegate
didFinishLaunchingWithOptions
方法使用:
[self.window addSubview:aView];
希望能帮助到你...
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)