Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A little problem for custom back button #4

Open
wonderffee opened this issue Sep 11, 2015 · 3 comments
Open

A little problem for custom back button #4

wonderffee opened this issue Sep 11, 2015 · 3 comments

Comments

@wonderffee
Copy link

If custom back button is used, pressing back button may cause redisplay of default back button(iOS 8.1, iPhone6). So for this case, "subview.alpha = 1.;" is not necessary.

@onegray
Copy link
Owner

onegray commented Feb 13, 2016

Probably this is fixed by 834617d ?

@pusswzy
Copy link

pusswzy commented Sep 7, 2017

因为是自定义按钮 所以不会调用- (BOOL)navigationBar:(UINavigationBar *)navigationBar shouldPopItem:(UINavigationItem *)item 所以你的框架就没有用了

@polo2244
Copy link

I had the same issue this was the solution for me.
When using custom image for your back button, iOS does not remove the actual back button,
it only fades to to alpha 0. And the interception function was re-seting the back button to 1.

If you customized the back button globally like this:

UIImage *backbutton= [[UIImage tintableImageNamed:@"back-button.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0) resizingMode:UIImageResizingModeTile];
[[UIBarButtonItem appearance] setBackButtonBackgroundImage:backbutton forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];

Then you should add this in :
- (BOOL)navigationBar:(UINavigationBar *)navigationBar shouldPopItem:(UINavigationItem *)item

BOOL hasCustomImage = [[UIBarButtonItem appearance] backButtonBackgroundImageForState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
        if (!hasCustomImage) {
             // Workaround for iOS7.1. Thanks to @boliva - http://stackoverflow.com/posts/comments/34452906
            for(UIView *subview in [navigationBar subviews]) {
                if(subview.alpha < 1.) {
                    [UIView animateWithDuration:.25 animations:^{
                        subview.alpha = 1.;
                    }];
                }
            }
        }

Can you confirm that this works for you ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants