My goal is to draw an invisible button above the status bar at the top of my iPhone application (size 320 * 20 pixels).
No matter what I try, something is not good:
For example, I tried to create a new view. When I want to place a view at the top of my application, it always disappears behind the status bar, not in front of it!
I found another great idea in Stackoverflow: Add a UIView over all other views, including the StatusBar. Even if the second UIWindow is not recommended, I tried to implement it. It worked the way I wanted until I noticed a problem: the keyboard no longer appears when necessary (for example, when clicking in a text field)!
How can i fix this? Or is there a better approach to my problem? This is my code for creating a second window:
// 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];
iphone uiview keyboard statusbar uiwindow
andreas
source share