iOS 7 Status Bar Turns Black When Overriding UINav

2019-05-30 14:04发布

问题:

I am subclassing the UINavigationBar so that I can override the drawRect method. However, when I do so in iOS 7, the status bar becomes completely black. No text at all. In iOS 6 it doesn't have that problem; the status bar is where it should be.

- (void)drawRect:(CGRect)rect // status bar goes pitch black
{
    [super drawRect:rect];
}

If I comment out this method, the status bar returns. How can I get the status bar back?


UPDATE Apr 15, 2014

I tried to set the status bar to something else using the code that I found here but it does not seem to have any effect.

回答1:

A solution I found. The text was initially black on top of a black background. I have not figured out how to make the background transparent, but I guess having white text is good enough.

https://stackoverflow.com/a/18184831/3400034