这是我的问题:我试图显示一个带有子视图的 UIWindow,该子视图显示径向渐变。我想把窗口放在 UIWindowLevelAlert 上。我之前已经弄清楚了这一切并且它正在工作,但现在我试图重现它浪费时间......这是我得到的代码(背景不是渐变,因为我想保持简单,然后添加一个真正类似于 UIAlertView 的视图):
- (IBAction)buttonPressed {
UIWindow *backgroundWindow = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];
backgroundWindow.windowLevel = UIWindowLevelAlert;
UIView *backgroundView = [[UIView alloc]initWithFrame:[UIScreen mainScreen].bounds];
backgroundView.backgroundColor = [UIColor blackColor];
backgroundView.alpha = 0.5;
[backgroundWindow makeKeyAndVisible];
[backgroundWindow addSubview:backgroundView];
backgroundWindow.hidden = NO;
}