Back button is not visible in iOS 7

旧街凉风 提交于 2019-11-29 14:23:22

问题


I have some weird trouble about iOS 7. I have an UINavigationBar in my app and it works perfect for iOS 6;

-- IOS 6 --

However, when i try to run it on iOS 7, my back button disappeared. It's there, still working and clickable but not visible;

-- IOS 7 --

How can I fix this problem ?


回答1:


Setting BackButtonBackgroundImage via UIAppearance currently has some odd behavior in iOS 7. This is probably related to the updated design, which replaces the rect-style button with a backIndicatorImage (an arrow).

This leaves 3 options for customizing the back button's appearance:

  1. Change the color of the backIndicatorImage by setting the tintColor property on UINavigationBar (or one of its superclasses).

  2. Set the new backIndicatorImage property on UINavigationBar to a custom image. (don't forget to set the backIndicatorTransitionMaskImage as well or it won't work)

  3. Create a custom UIBarButtonItem and manually assign it as UINavigationItem's leftBarButtonItem. (See the answer mentioned above by Mashhadi)




回答2:


By the way, if you have to keep support ios 6 version like me, use that;

   if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1)
        {
            // My iOS 6 back button background 
            self.navigationController.navigationBar.tintColor = [UIColor colorWithRed:39.0f/255.0f green:184.0f/255.0f blue:199.0f/255.0f alpha:1.0];
        }
        else
        {
            self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
        }



回答3:


I used Wes Dearborn's answer and implemented a nice way of supporting both iOS5+'s back button and iOS7's backIndicatorImage:

Back button strangely disappearing in UINavigationController but keeps working



来源:https://stackoverflow.com/questions/18617522/back-button-is-not-visible-in-ios-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!