Вопрос

I'm integrating a passbook system in my iOS app. I'm using the PassKit framework (Obviously ;) ). I'm using a custom tint color for all my navigation items. Is it possible to change the color of the 'Cancel' and 'Add' button? (From te PKAddPassesViewController) The blue looks horrible in my design.

thanks

Это было полезно?

Решение 3

I don't think that you can change the tintcolor. Since iOS 6 such viewControllers are based on remote view controllers, meaning their view is completely owned by another process and inaccessible programatically.

This can be confirmed by looking at the recursive description of the controller's view:

<UIView: 0x140b0780; frame = (0 0; 320 568); layer = <CALayer: 0x140b0860>>
|    | <_UISizeTrackingView: 0xe3b7300; frame = (0 20; 320 548); clipsToBounds = YES; autoresize = W+H; layer = <CALayer: 0xe3b7410>>
|    |    | <_UIRemoteView: 0xe3b9b80; frame = (0 0; 320 568);

The _UIRemoteView indicates that the contents of the view is hosted in another process.

Edit:

Curiosly with MFMailComposeViewController it works. This viewController has an addressable navigationbarcontroller.

Другие советы

In iOS 9 the button color can be changed. Subclass the PKAddPassesViewController and set the window tintcolor in viewWillAppear and make sure to set it back back in viewWillDisappear. Then use your subclass instead of PKAddPassesViewController:

MyPKAddPassesViewController.h:

#import <PassKit/PassKit.h>

@interface LHPKAddPassesViewController : PKAddPassesViewController

@end

MyPKAddPassesViewController.m:

#import "LHPKAddPassesViewController.h"

@implementation LHPKAddPassesViewController

- (void) viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    ((UIWindow *)[UIApplication sharedApplication].keyWindow).tintColor = [UIColor greenColor];
}

- (void) viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    ((UIWindow *)[UIApplication sharedApplication].keyWindow).tintColor = [UIColor whiteColor];
}

@end

There a simple way to do this in iOS 9. In the caller of PKAddPassesViewController use this:

PKAddPassesViewController *addToPassbookController = init...

[addToPassbookController.view setTintColor:[UIColor blackColor];

In Storyboard, Select navigationbar of your UINavigationController and then select the tint color

enter image description here

Hope this will help for you

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top