This question already has an answer here:
Hi I have a game where I create a subview that handles touch events. But when I add other objects later in the code, they appear in front of that view. So if the user tap the screen on one of these objects the touch won't be registered.
So is there a way to make a UIView always appear on the top?
I have tried this, but it doesn't work:
view.layer.zPosition = MAXFLOAT;
Any ideas? Thanks
If for some reason you don't want to keep a pointer to the subview as others have suggested you can add subviews using this method:
with index = 0. This will insert each new subview under the previous. I would personally probably still do what @Alexander is doing in his answer/comments.
Try with
bringSubviewToFront:
, did the trick for me: