簡體   English   中英

更改底部工具欄項目的顏色

[英]change BOTTOM toolbar items color

我的屏幕上有一個簡單的工具欄。 該工具欄有兩個按鈕。 第一個應該是黑色,第二個應該是藍色。 已經更改了代碼和情節提要的顏色,但是當我運行兩個仍為黑色的應用程序時。 如何僅更改第二項的顏色?

這是我的工具欄;

在此處輸入圖片說明

這是我的代碼:

- (void)viewDidLoad {
    [super viewDidLoad];
    self.deviceImages.delegate = self;
    self.deviceImages.dataSource = self;
    [self.rigthToolbarItem setTintColor:[UIColor colorWithRed:82/255.0 green:157/255.0  blue:230/255.0  alpha:1.0]];
}

解決方案1:

基本上,您必須創建一個UIButton,根據需要進行配置,然后使用UIButton作為自定義視圖來初始化Bar Button Item。 喜歡:

UIButton *button = [UIButton buttonWithType:....];
...(customize your button)...

UIBarButtonItem *barButton = [[UIBarButtonItem alloc] initWithCustomView:button];

要么

解決方案2:

更改標題的顏色:iOS7:

UIBarButtonItem *button = 
 [[UIBarButtonItem alloc] initWithTitle:@"Title" 
                                  style:UIBarButtonItemStyleBordered 
                                 target:nil 
                                 action:nil];
[button setTitleTextAttributes:
          [NSDictionary dictionaryWithObjectsAndKeys: 
               [UIColor redColor], NSForegroundColorAttributeName,nil] 
                                            forState:UIControlStateNormal];

and prior iOS7:

UIBarButtonItem *button = 
  [[UIBarButtonItem alloc] initWithTitle:@"Title" 
                                   style:UIBarButtonItemStyleBordered 
                                  target:nil 
                                  action:nil];
[button setTitleTextAttributes:
          [NSDictionary dictionaryWithObjectsAndKeys: 
               [UIColor redColor], UITextAttributeTextColor,nil] 
                                    forState:UIControlStateNormal];

希望能為您的問題找到解決方案。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM