How to make a UIView always appear at the front?

Viewed 38995

Currently I have a UIView which contains some controls. I then have some images I programatically add to the view to display as animations. Currently at the end of each interval of my game loop im having to tell the controller to move the UIView control to the front, otherwise the images will appear on top of it. Is there a less costly method of making it persist as always on top.

Currently I have the following at the end of my game loop:

[self.view bringSubviewToFront:myControlView];

Could I do something like this when the game initiates:

myControlView.alwaysOnTop = true;
6 Answers

just remember there is this method too,

- (void)insertSubview:(UIView *)view aboveSubview:(UIView *)siblingSubview

Another solution would be to create an invisible container view for all your other views. Add that container view first to your main view, and the UIView you want to have on top after that. Then add all your other views to the container view, instead of to the main view.

Related