1

Web ビューをナビゲートするためのツールバーを作成しているアプリケーションがありました。ボタンの色を除いて、すべて正常に動作しています。ツールバーを有効にすると白く表示されますが、ボタンをそのまま表示する必要があります。

[self.navigationController setToolbarHidden:NO animated:YES];

    self.navigationController.toolbar.barStyle = UIBarStyleBlackTranslucent;


    self.navigationController.toolbar.tintColor=[UIColor colorWithRed:215/255.0 green:215/255.0 blue:215/255.0 alpha:1.0];  
    buttonGoBack = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"back_icon.png"] style:UIBarButtonItemStylePlain target:self action:@selector(backButtonTouchUp:)];

    UIBarButtonItem *fixedSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
    fixedSpace.width = 30;

    buttonGoForward = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"forward_icon.png"] style:UIBarButtonItemStylePlain target:self action:@selector(forwardButtonTouchUp:)];

    UIBarButtonItem *flexibleSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];



    buttonAction = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(buttonActionTouchUp:)];

    UIBarButtonItem *buttonContainer = [[UIBarButtonItem alloc] initWithCustomView:containerView];
    [containerView release];
    NSMutableArray *toolBarButtons = [[NSMutableArray alloc] init];
    [toolBarButtons addObject:buttonGoBack];
    [toolBarButtons addObject:fixedSpace];
    [toolBarButtons addObject:buttonGoForward];
    [toolBarButtons addObject:flexibleSpace];
    [toolBarButtons addObject:buttonContainer];
    [toolBarButtons addObject:flexibleSpace];
     [toolBarButtons addObject:buttonAction];



    // Set buttons to tool bar
    [self.navigationController.toolbar setItems:toolBarButtons animated:YES];

`

ボタンが有効な場合のボタンの元の色を取得するにはどうすればいいですか = NO; 誰か助けてくれますか

4

2 に答える 2

0

私は解決策を見つけました。誰かが同じ問題に直面している場合は、喜んで共有します。

[[UIBarButtonItem appearance] setTintColor:[UIColor redColor]];

このようにして、バーボタンに任意の色を付けることができます。

于 2013-07-15T11:43:30.863 に答える