Iphone 如何在状态栏上添加按钮或视图

Iphone 如何在状态栏上添加按钮或视图,iphone,objective-c,ios,statusbar,Iphone,Objective C,Ios,Statusbar,我想在iPhone的状态栏上添加一个按钮或自定义视图 如果苹果不允许自定义状态栏,那么可以在状态栏上添加任何按钮或视图 有没有人对此有想法请与我分享 谢谢您可以获得静态库模拟Reeders状态栏覆盖,您可以在这里找到它 或者只需创建一个简单的UIWindow子类,并覆盖initWithFrame: @interface ACStatusBarOverlayWindow : UIWindow { } @end @implementation ACStatusBarOverlayWindow -

我想在iPhone的状态栏上添加一个按钮或自定义视图

如果苹果不允许自定义状态栏,那么可以在状态栏上添加任何按钮或视图

有没有人对此有想法请与我分享


谢谢

您可以获得静态库模拟Reeders状态栏覆盖,您可以在这里找到它

或者只需创建一个简单的
UIWindow
子类,并覆盖
initWithFrame

@interface ACStatusBarOverlayWindow : UIWindow {
}
@end

@implementation ACStatusBarOverlayWindow
- (id)initWithFrame:(CGRect)frame {
    if ((self = [super initWithFrame:frame])) {
        // Place the window on the correct level and position
        self.windowLevel = UIWindowLevelStatusBar+1.0f;
        self.frame = [[UIApplication sharedApplication] statusBarFrame];

        // Create an image view with an image to make it look like a status bar.
        UIImageView *backgroundImageView = [[UIImageView alloc] initWithFrame:self.frame];
        backgroundImageView.image = [[UIImage imageNamed:@"statusBarBackgroundGrey.png"] stretchableImageWithLeftCapWidth:2.0f topCapHeight:0.0f];
        [self addSubview:backgroundImageView];
        [backgroundImageView release];

        // TODO: Insert subviews (labels, imageViews, etc...)
    }
    return self;
}
@end
有关更多信息,请参阅此链接


我希望这能帮助你…

你可以得到静态库模拟里德斯状态栏覆盖,你可以在这里找到它

或者只需创建一个简单的
UIWindow
子类,并覆盖
initWithFrame

@interface ACStatusBarOverlayWindow : UIWindow {
}
@end

@implementation ACStatusBarOverlayWindow
- (id)initWithFrame:(CGRect)frame {
    if ((self = [super initWithFrame:frame])) {
        // Place the window on the correct level and position
        self.windowLevel = UIWindowLevelStatusBar+1.0f;
        self.frame = [[UIApplication sharedApplication] statusBarFrame];

        // Create an image view with an image to make it look like a status bar.
        UIImageView *backgroundImageView = [[UIImageView alloc] initWithFrame:self.frame];
        backgroundImageView.image = [[UIImage imageNamed:@"statusBarBackgroundGrey.png"] stretchableImageWithLeftCapWidth:2.0f topCapHeight:0.0f];
        [self addSubview:backgroundImageView];
        [backgroundImageView release];

        // TODO: Insert subviews (labels, imageViews, etc...)
    }
    return self;
}
@end
有关更多信息,请参阅此链接

我希望这能帮助你