youknowone / UI7Kit

Backport flat-style UIKit from iOS7 to iOS5+
Other
1.67k stars 199 forks source link

UINavigation Back Button not working #130

Open gilthonweapps opened 10 years ago

gilthonweapps commented 10 years ago

Hi,

If I change the "back" button of my navigation bar, it style uses the iOS6 layout.

Here is the code I use:

self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Back", nil) style:UIBarButtonItemStyleBordered target:nil action:nil];

gilthonweapps commented 10 years ago

It doesn't work only when the view is not pushed inside a navigationcontroller.

hatunike commented 10 years ago

My temp fix is bad (and really don't recommend unless you GOTTA have this working right). I stopped UI7 kit from handling my UINavigationBar, UINavigationController, and UINavigationItem. (remove those class names from UI7KitCore patch method).

And then in my App delegate appDidFinishLaunching method I'm just using [UINavigationBar appearance] methods to mimick the iOS7 look and feel. This is actually easier than you'd think because you can pretty much just use the same implementation that ui7Kit uses. For example, the back button :

    UIImage *backImage = [UIImage imageNamed:@"UI7NavigationBarBackButton"];
    backImage = [backImage imageByFilledWithColor:tintColor];
    [[UIBarButtonItem appearance] setBackButtonBackgroundImage:backImage forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
    backImage = [backImage imageByFilledWithColor:tintColor];
    [[UIBarButtonItem appearance] setBackButtonBackgroundImage:backImage forState:UIControlStateHighlighted barMetrics:UIBarMetricsDefault];

I've got my tint color defined above and I also import #import "UIImage.h"

import "UI7Color.h".

This is definitely only recommended if you are really having back button issues.