1

我目前有一个连接到情节提要的粒子视图。我面临的问题是在显示此视图的同时显示警报,并且警报始终显示在粒子视图的前面。有没有一种方法可以让我始终将粒子视图放在前面?我正在使用一个名为 SIAlertView 的第三方警报库,所以我假设它是可能的。

我已经记录了 alertView 的 zPosition 并且它始终为 0,所以我将粒子视图层的 zPosition 设置为 10,但它仍然显示在警报视图下方。

这是故事板层次结构:

在此处输入图像描述

4

1 回答 1

1

我不知道 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;
于 2014-04-18T08:05:17.213 回答