我想添加一个按钮或在iPhone的状态栏上的任何自定义视图,如何在状态栏上添加按钮或任何视图?
如果苹果不允许自定义状态栏比它可以通过状态栏添加任何按钮或视图...
有没有人有关于此的想法请与我分享。
感谢,
我想添加一个按钮或在iPhone的状态栏上的任何自定义视图,如何在状态栏上添加按钮或任何视图?
如果苹果不允许自定义状态栏比它可以通过状态栏添加任何按钮或视图...
有没有人有关于此的想法请与我分享。
感谢,
[[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];
一个好主意
UIWindow *statusWindow = [[UIWindow alloc] initWithFrame:CGRectMake(0,0,320,20)];
statusWindow.windowLevel = UIWindowLevelStatusBar;
statusWindow.backgroundColor=[UIColor redColor];
我的任何一个回答将有助于全给我也 – 2012-02-15 05:21:09
这个SO后可以帮助你http://stackoverflow.com/questions/2833724/adding-view -on-statusbar-in-iphone – Maulik 2012-02-15 05:42:42
谢谢Maulik ...我得到它我想要的任何东西.. :) – Raj 2012-02-15 06:06:06