簡體   English   中英

iOS狀態欄不會太亮

[英]iOS Status Bar Won't Stay Light

在我的App Delegate中,我有以下代碼,但在導航欄上方完全看不到,您看不到任何內容。 如果我刪除導航欄的背景圖像,它會正確顯示為淺色內容,但是我不確定當出現時會阻止什么。 UINavigationBar的背景圖像為320x44。

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{

    UIImage *theBackground = [[UIImage imageNamed:@"navbar.png"]resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)];;
    if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1) {
        // Load resources for iOS 6.1 or earlier
       // UIColor *purple = UIColorFromRGB(0x95cdde);
        [[UINavigationBar appearance] setBackgroundImage:theBackground forBarMetrics:UIBarMetricsDefault];



    } else {
        // Load resources for iOS 7 or later
       // UIColor *purple = UIColorFromRGB(0x95cdde);

        [[UINavigationBar appearance] setBackgroundImage:theBackground forBarMetrics:UIBarMetricsDefault];

    }
    window.rootViewController = tabBarController;
    [window makeKeyAndVisible];
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];

    return YES;
}

這是導航欄圖像 在此處輸入圖片說明

好的,這就是我的理解。 如果我錯了,希望有人糾正我。 在iOS 7中,導航欄背景圖像也在狀態欄下方擴展。 因此,導航欄背景圖像很可能會阻塞狀態欄。

在我的應用中,我遇到了同樣的問題。 我有一個圖像選擇器,按下該控制器時,狀態欄內容變暗。 以下代碼為我解決了這個問題

- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent
                                            animated:NO];
}

我還必須將UIViewController設置為UINavigationControllerDelegate

http://blog.jaredsinclair.com/post/61507315630/wrestling-with-status-bars-and-navigation-bars-on-ios-7上找到了這篇文章,這有助於我弄清我的問題。 需要將此添加到我的plist中

基於ViewController的狀態欄外觀並將其設置為NO

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM