Bringing a subview to be in front of all other views

Mark S picture Mark S · Nov 1, 2012 · Viewed 116.7k times · Source

I am working on integrating an ad provider into my app currently. I wish to place a fading message in front of the ad when the ad displays but have been completely unsuccessful.

I made a function which adds a subview to my current view and tries to bring it to the front using

[self.view bringSubviewToFront:mySubview]

The function fires on notification that the ad loaded (the notification is from the adprovider's SDK). However, my subview does not end up in front of the ad. I imagine this is made purposely difficult by the ad provider, but I wish to do it regardless. I am currently discussing with the provider whether or not this can be allowed. But for the time being, I just want to see if it's even possible.

Is there anyway I can force a subview of mine to be the top-most view such that it will not be obstructed by anything?

Answer

daniel kilinskas picture daniel kilinskas · Apr 2, 2015

try this:

self.view.layer.zPosition = 1;