ナビゲーション バーの背景色の設定を手伝っていただければ幸いです。下の最初の写真でわかるように、バーは水色/灰色ですが、2番目の写真「Favoritter」のようにしたい.
私のプロジェクトには別のviewControllerがあります(2番目の写真「Favoritter」を参照)。しかし、ここで何が間違っているのかわかりません。navigationBar は、この水色/灰色のみを使用し、黄色は使用しません。
私のコードは次のようなものです:
------------------InstantCabAppDelegate.m ファイル-----------START-------
//InstantCabAppDelegate.m file
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Create tabBarController instance
tabBarController = [[UITabBarController alloc] initWithNibName:nil bundle:nil];
// Create instances of navigation controller and view controllers
orderController = [[OrderController2 alloc] initWithNibName:@"Order2" bundle:nil];
UINavigationController* firstnavigationController = [[UINavigationController alloc] initWithRootViewController:orderController];
ICStatusViewController *statusController = [[ICStatusViewController alloc] initWithStatus];
UINavigationController *statusNavController = [[UINavigationController alloc] initWithRootViewController:statusController];
ICSettingsViewController *settingsController = [[ICSettingsViewController alloc] init];
UINavigationController *settingsNavController = [[UINavigationController alloc] initWithRootViewController:settingsController];
UIViewController *company_controller = nil;
company_controller = [[ICCompaniesGridController alloc] initWithCompanies:[[NSArray alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Companies" ofType:@"plist"]]];
tabBarController.viewControllers = [NSArray arrayWithObjects:firstnavigationController, settingsNavController, statusNavController, company_controller, nil];
[window setRootViewController:tabBarController];
[window makeKeyAndVisible];
return YES;
}
------ICStatusViewController.m ファイル-----------START-------
// ICStatusViewController.m file
#import "ICStatusViewController.h"
#import "LocalizationSystem.h"
#import "ICTemporaryStore.h"
#import "Debug.h"
@implementation ICStatusViewController
@synthesize doneCallbackBlock=_doneCallbackBlock, cancelCallbackBlock=_cancelCallbackBlock;
@synthesize myTableView, no_statuses, no_statuses_label, delegate;
- (id)initWithStatus
{
if ((self = [super initWithNibName:@"StatusList" bundle:nil]))
{
self.title = AMLocalizedString(@"kStatusTitle", @"");
self.tabBarItem.image = [UIImage imageNamed:@"status_icon"];
self.no_statuses = AMLocalizedString(@"kStatusListNoStatusList", @"");
first_color = TABLE_VIEW_BACKGROUND_COLOR;
second_color = first_color;
self.doneCallbackBlock = nil;
self.cancelCallbackBlock = nil;
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
self.parentViewController.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"background-nologo"]];
self.view.backgroundColor = [UIColor clearColor];
self.myTableView.backgroundColor = TABLE_VIEW_BACKGROUND_COLOR;
if ([statusObjects count] == 0)
{
self.myTableView.hidden = YES;
self.no_statuses_label.text = self.no_statuses;
self.no_statuses_label.hidden = NO;
no_status_background.hidden = NO;
}
[self.no_statuses_label setTextColor:[UIColor colorWithRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:1.0]];
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
if ([statusObjects count] == 0)
{
self.myTableView.hidden = YES;
self.no_statuses_label.text = self.no_statuses;
self.no_statuses_label.hidden = NO;
no_status_background.hidden = NO;
self.navigationItem.rightBarButtonItem = nil;
}
else
{
self.myTableView.hidden = NO;
self.no_statuses_label.hidden = YES;
no_status_background.hidden = YES;
}
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
NSInteger retval = 0;
for (int i=0; i<[statusObjects count]; i++)
{
StatusObj *add = [statusObjects getStatusAtIndex:i];
if (add.status_id && [add.status_id length] > 0 && [add.status_type isEqualToString:@"STATUS_ORDER"])
{
retval++;
}
}
return retval;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifierStatus = @"StatusCell";
__unsafe_unretained NSString *CellIdentifier = CellIdentifierStatus;
StatusCell* cell = (StatusCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[StatusCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
[[cell textLabel] setTextColor:TABLE_VIEW_TEXT_LABEL_COLOR];
[[cell detailTextLabel] setTextColor:TABLE_VIEW_DETAIL_TEXT_LABEL_COLOR];
[[cell detailTextLabel] setNumberOfLines:3];
}
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
dateString = [dateFormat stringFromDate:current_order.order.time];
NSString *str = AMLocalizedString(@"kStatusListDetailsToDay", @"");
textLabelString = [NSString stringWithFormat:@"%@ - %@", str, dateString];
[cell.textLabel setText:textLabelString];
[cell.detailTextLabel setText:detailTextString];
[cell setBackgroundColor:[UIColor redColor]];
[cell.dateLabel setBackgroundColor:[UIColor clearColor]];
cell.accessoryType = UITableViewCellAccessoryNone;
return cell;
}
------ICStatusViewController.h ファイル-----------START-------
// ICStatusViewController.h
#import <UIKit/UIKit.h>
#import "Status.h"
#import "StatusCell.h"
#import "StatusControllerDelegate.h"
#import "ICStatusDetailsController.h"
typedef void (^ICStatusViewControllerDoneCallbackBlock)(id userInfo);
typedef void (^ICStatusViewControllerCancelCallbackBlock)(void);
@interface ICStatusViewController : UIViewController <UITableViewDelegate, UITableViewDataSource, UIActionSheetDelegate, ICStatusDetailsControllerDelegate> {
id<Statuses> statusObjects;
NSString *no_statuses;
NSOperationQueue *queue;
NSTimer *statusTimer;
__unsafe_unretained id<StatusControllerDelegate> delegate;
UIColor *first_color;
UIColor *second_color;
IBOutlet __unsafe_unretained UITableView *myTableView;
IBOutlet __unsafe_unretained UILabel *no_statuses_label;
IBOutlet __unsafe_unretained UIImageView *no_status_background;
@private
ICStatusViewControllerDoneCallbackBlock _doneCallbackBlock;
ICStatusViewControllerCancelCallbackBlock _cancelCallbackBlock;
}
@property (nonatomic, unsafe_unretained) UITableView* myTableView;
@property (nonatomic, copy) NSString* no_statuses;
@property (nonatomic, unsafe_unretained) UILabel* no_statuses_label;
@property (nonatomic, unsafe_unretained) id <StatusControllerDelegate> delegate;
@property (nonatomic, copy) ICStatusViewControllerDoneCallbackBlock doneCallbackBlock;
@property (nonatomic, copy) ICStatusViewControllerCancelCallbackBlock cancelCallbackBlock;
- (id)initWithStatus;
@end