我的目标是在iPhone应用程序顶部的状态栏上方绘制一个隐形按钮(尺寸为320 * 20像素)。在状态栏上方放置UIView或UIWindow
无论我怎么努力,事情是越野车:
例如,我试图创建一个新的观点。当我想将视图置于应用程序的顶部时,它总是在状态栏后面消失,而不是位于它的前面!
我发现#2另一个伟大的想法: Add UIView Above All Other Views, Including StatusBar 即使不推荐第二的UIWindow,我试图实现它。它工作正如我想要的,直到我注意到一个问题:键盘在需要时不再出现(例如,当在文本框中单击时)!
我该如何解决这个问题?还是有更好的方法来解决我的问题?这是我创建的第二个窗口代码:
// 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];
你好,这太棒了!首先,我不相信它可以工作,但实际上它确实!非常感谢您为我节省时间和挫折! :-) – andreas 2010-11-23 23:28:14
你最终使用了哪种方法? – 2010-11-24 02:42:47