我想在iPhone的状态栏中添加按钮或任何自定义视图,
如果苹果不允许自定义状态栏,则可以在状态栏上添加任何按钮或视图...
有没有人对此有所了解请与我分享。
谢谢,
答案 0 :(得分:1)
您可以隐藏默认状态栏并创建与状态栏具有相同高度的自定义栏,并将其显示在视图上。除了更改颜色(灰色/黑色),不透明度(不透明/半透明)和可见性(隐藏/可见)之外,Apple不允许您自定义状态栏。
答案 1 :(得分:1)
[[UIApplication sharedApplication]setStatusBarHidden:YES withAnimation:NO];
// Create window
UIWindow *statusWindow = [[UIWindow alloc] initWithFrame:CGRectMake(0,0,320,20)];
statusWindow.windowLevel = UIWindowLevelStatusBar;
statusWindow.backgroundColor=[UIColor redColor];
// Dont make the statusWindow keyWindow or the keyboard won't work!
// [statusWindow makeKeyAndVisible];
// Create statusBarButton
UIButton *statusBarButton = [UIButton buttonWithType:UIButtonTypeContactAdd];
statusBarButton.frame = CGRectMake(230, 2, 15, 15);
statusBarButton.backgroundColor=[UIColor redColor];
[statusBarButton addTarget:self action:@selector(goTop) forControlEvents:UIControlEventTouchUpInside];
// Place button into the new window
// Instead, add this:
[self.window makeKeyAndVisible]; // has to be main window of app
statusWindow.hidden = NO;
[statusWindow addSubview:statusBarButton];
答案 2 :(得分:1)
一个好主意
UIWindow *statusWindow = [[UIWindow alloc] initWithFrame:CGRectMake(0,0,320,20)];
statusWindow.windowLevel = UIWindowLevelStatusBar;
statusWindow.backgroundColor=[UIColor redColor];