【发布时间】:2015-01-12 21:55:11
【问题描述】:
我想制作某种自定义警报视图 - 功能基本相同,但外观不同。据我所知, UIAlertView 显示在一个单独的窗口中。我可以创建一个窗口,将视图放入其中并显示它,但如果没有对 UIWindow 对象的强引用,它会在函数返回后立即消失。另一方面,可能没有对 UIAlertView 的强引用,但它显示后并没有消失。如何为我的警报窗口实现相同的行为?
// create a new window
UIWindow *alertWindow = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
alertWindow.windowLevel = UIWindowLevelAlert;
UIToolbar *background = [[UIToolbar alloc] initWithFrame:alertWindow.frame];
background.barStyle = UIBarStyleBlack;
background.translucent = YES;
[alertWindow addSubview:background];
[alertWindow addSubview:contentView];
[alertWindow makeKeyAndVisible];
【问题讨论】:
标签: ios uialertview uiwindow