I have a problem with sendSubviewToBack and insertSubview:belowSubview: methods. Simply, I have a button which I’m inserting below another view _centerView. I want the button to stay below the _centerView.
The problem I’m facing is that when I insert a button below the _centerView I see a flicker (just for a short moment) over the _centerView. I tried both sendSubviewToBack: and insertSubview:belowSubview: – same effect.
Do you have any ideas what things may be wrong? Am I missing something? Here is my code:
UIButton* itemButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[itemButton setFrame:CGRectMake(0, 0, 40, 40)];
[itemButton setCenter:_centerView.center];
[parentView bringSubviewToFront:_centerView];
[parentView insertSubview:itemButton belowSubview:_centerView];
OK, so after a while it turned out that this is the fault of the window I animated the same time I added the button. I don’t know why but the fade in animation of the window was causing this problem. I switched of the animations of my UIWindow and now it works. Thanks for help!