Note that there are some explanatory texts on larger screens.

plurals
  1. POPutting a UIView or UIWindow above Statusbar
    text
    copied!<p>My goal is to draw an invisible button above the status bar on the top of my iPhone app (dimension 320*20 pixels).</p> <p>No matter what I try, something is buggy:</p> <ol> <li><p>For example, I tried to create a new view. When I want to place the view on the top of my app, it always disappears behind the status bar instead of being in front of it!</p></li> <li><p>I found another great idea on Stackoverflow: <a href="https://stackoverflow.com/questions/2666792/add-uiview-above-all-other-views-including-statusbar">Add UIView Above All Other Views, Including StatusBar</a> Even if a second UIWindow isn't recommended, I tried to implement it. It worked as I wanted until the moment that I noticed a problem: the keyboard doesn't appear anymore when needed (for example when clicking in a textbox)! </p></li> </ol> <p>How can I possibly fix this? Or is there a better approach to my problem? This is my code for creating the second window:</p> <pre><code>// Create window statusWindow = [[UIWindow alloc] initWithFrame:CGRectMake(0,0,320,20)]; statusWindow.windowLevel = UIWindowLevelStatusBar; [statusWindow makeKeyAndVisible]; // Create statusBarButton statusBarButton = [UIButton buttonWithType:UIButtonTypeCustom]; CGRect buttonFrame2 = statusBarButton.frame; buttonFrame2.size = CGSizeMake(320,20); statusBarButton.frame = buttonFrame2; [statusBarButton addTarget:self action:@selector(goTop) forControlEvents:UIControlEventTouchUpInside]; // Place button into the new window [statusWindow addSubview:statusBarButton]; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload