Pregunta

I currently have a particle view connected to storyboard. The problem that I'm facing is that I'm displaying an alert at the same time I show this view, and the alert is always shown in front of the particle view. Is there a way where I can always place the particle view in front? I'm using a third party alert library titled SIAlertView, so I'm assuming it may be possible.

I've logged the zPosition of the alertView and it's always 0, so I set the zPosition of my particle view's layer to 10, but it is still shown beneath the alert view.

Here's the storyboard hierarchy:

enter image description here

¿Fue útil?

Solución

I do not know about SIAlertView but normal UIAlertView is shown via separate window. If you want to overlap it you can not do it by changing zpozition, you have to also use a separate window:

// 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!

UPDATE:

To overlap also a status bar use

notificationWindow.windowLevel = UIWindowLevelStatusBar;

to dismiss UIWindow just invalidate strong pointer to it. Something like:

self.strongPointerToYourWindow = nil;
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top