我目前有一个连接到 Storyboard的粒 subview 。我面临的问题是我在显示此 View 的同时显示警报,并且警报始终显示在粒 subview 的前面。有没有办法让我始终将粒 subview 放在前面?我正在使用名为 SIAlertView 的第三方警报库,所以我假设它可能是可行的。
我已经记录了 alertView 的 zPosition,它始终为 0,所以我将粒 subview 图层的 zPosition 设置为 10,但它仍然显示在警报 View 下方。
这是 Storyboard 层次结构:
最佳答案
我不知道 SIAlertView,但正常的 UIAlertView 是通过单独的窗口显示的。如果你想重叠它,你不能通过改变 zpozition 来实现,你还必须使用一个单独的窗口:
// do not forget to keep strong reference for it somewhere!
UIWindow *notificationWindow;
//your frame here!
notificationWindow = [[UIWindow alloc] initWithFrame: some_cgrect];
notificationWindow.backgroundColor = [UIColor clearColor]; // your color if needed
notificationWindow.userInteractionEnabled = NO; // if needed
// IMPORTANT PART!
notificationWindow.windowLevel = UIWindowLevelAlert + 1;
notificationWindow.rootViewController = [UIViewController new];
notificationWindow.hidden = NO; // This is also important!
更新:
重叠状态栏使用
notificationWindow.windowLevel = UIWindowLevelStatusBar;
关闭 UIWindow 只是使指向它的强指针无效。像这样的东西:
self.strongPointerToYourWindow = nil;
关于ios - 将粒 subview 移动到屏幕前面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23149901/