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

时间:2012-12-17 09:52:08

标签: iphone objective-c ios statusbar

我想在iPhone的状态栏中添加按钮或自定义视图,

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

有没有人对此有所了解请与我分享。

由于

1 个答案:

答案 0 :(得分:4)

哟可以获得静态库模仿Reeders状态栏叠加,你可以在这里找到它

MTStatusBarOverlay

或者只需使用以下覆盖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

有关详细信息,请参阅此链接...

adding-view-on-statusbar-in-iphone

我希望这可以帮助你...