Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xcode/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 如何在UINavigationBar上设置背景色(tintColor)_Iphone_Xcode_Uinavigationbar_Tintcolor - Fatal编程技术网

Iphone 如何在UINavigationBar上设置背景色(tintColor)

Iphone 如何在UINavigationBar上设置背景色(tintColor),iphone,xcode,uinavigationbar,tintcolor,Iphone,Xcode,Uinavigationbar,Tintcolor,我希望你能帮我设置导航栏的背景色。正如您在下面的第一张图片上看到的,该条是浅蓝色/灰色的,但我希望它与第二张图片“Favoritter”类似 我的项目中有另一个viewController(请参见第二张图片“Favoriter”),它在那里工作。但我看不出我做错了什么,导航栏将只采用浅蓝色/灰色,而不是黄色 我的代码如下: ------------------InstantBapPDelegate.m文件----------开始------- ------------------ICStat

我希望你能帮我设置导航栏的背景色。正如您在下面的第一张图片上看到的,该条是浅蓝色/灰色的,但我希望它与第二张图片“Favoritter”类似

我的项目中有另一个viewController(请参见第二张图片“Favoriter”),它在那里工作。但我看不出我做错了什么,导航栏将只采用浅蓝色/灰色,而不是黄色

我的代码如下:

------------------InstantBapPDelegate.m文件----------开始-------

------------------ICStatusViewController.m文件----------开始-------

//ICStatusViewController.m文件
#导入“ICStatusViewController.h”
#导入“本地化系统.h”
#导入“ICTemporaryStore.h”
#导入“Debug.h”
@ICStatusViewController的实现
@合成doneCallbackBlock=\u doneCallbackBlock,cancelCallbackBlock=\u cancelCallbackBlock;
@综合myTableView、无状态、无状态标签、委托;
-(id)初始状态
{
if((self=[super initWithNibName:@“StatusList”bundle:nil]))
{
self.title=AMLocalizedString(@“kStatusTitle”,@“”);
self.tabBarItem.image=[UIImage ImageName:@“状态图标”];
self.no_statuses=AMLocalizedString(@“kStatusListNoStatusList”,“@”);
第一种颜色=表格视图背景颜色;
第二种颜色=第一种颜色;
self.doneCallbackBlock=nil;
self.cancelCallbackBlock=nil;
}
回归自我;
}
-(无效)viewDidLoad
{  
[超级视图下载];
self.parentViewController.view.backgroundColor=[UIColor-WithPatternImage:[UIImage-ImageName:@“background-nologo”];
self.view.backgroundColor=[UIColor clearColor];
self.myTableView.backgroundColor=表格\视图\背景\颜色;
如果([statusObjects count]==0)
{
self.myTableView.hidden=是;
self.no\u status\u label.text=self.no\u status;
self.no\u status\u label.hidden=否;
no_status_background.hidden=否;
}
[self.no_status_label setTextColor:[UIColor colorWithRed:255.0/255.0绿:255.0/255.0蓝:255.0/255.0 alpha:1.0];
}
-(无效)视图将显示:(BOOL)动画
{
[超级视图将显示:动画];
如果([statusObjects count]==0)
{
self.myTableView.hidden=是;
self.no\u status\u label.text=self.no\u status;
self.no\u status\u label.hidden=否;
no_status_background.hidden=否;
self.navigationItem.rightBarButtonItem=nil;
}
其他的
{
self.myTableView.hidden=否;
self.no\u status\u label.hidden=是;
no_status_background.hidden=是;
}
}
-(NSInteger)表视图:(UITableView*)表视图行数节:(NSInteger)节
{
NSInteger-retval=0;
对于(int i=0;i 0&[add.status\u type isEqualToString:@“status\u ORDER”])
{
retval++;
}
}
返回返回;
}
-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath
{
静态NSString*CellIdentifierStatus=@“StatusCell”;
__不安全\u未保存的NSString*CellIdentifier=CellIdentifierStatus;
StatusCell*cell=(StatusCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
如果(单元格==nil)
{
cell=[[StatusCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
[[cell textLabel]setTextColor:表\视图\文本\标签\颜色];
[[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];
[单元格设置背景颜色:[UIColor redColor]];
[cell.dateLabel setBackgroundColor:[UIColor clearColor]];
cell.accessoryType=UITableViewCellAccessoryNone;
返回单元;
}
------------------ICStatusViewController.h文件----------开始-------

//ICStatusViewController.h
#进口
#导入“Status.h”
#导入“StatusCell.h”
#导入“StatusControllerDelegate.h”
#导入“ICStatusDetailsController.h”
typedef void(^ICStatusViewControllerDoneCallbackBlock)(id userInfo);
typedef void(^ICStatusViewControllerCancellBackblock)(void);
@接口ICStatusViewController:UIViewController{
标识状态对象;
NSString*无_状态;
NSOperationQueue*队列;
NSTimer*状态计时器;
__不安全的\u未保留的id代表;
UIColor*第一种颜色;
UIColor*第二种颜色;
IBOutlet uu不安全u未维护的UITableView*myTableView;
IBOutlet uu不安全u未维护UILabel*无状态u label;
IBOutlet uu不安全u未维护UIImageView*无状态u背景;
@私人的
ICStatusViewControllerDoneCallbackBlock _doneCallbackBlock;
ICStatusViewControllerCancellBackblock _CancellBackblock;
}
@属性(非原子的、不安全的、未维护的)UITableView*myTableView;
@属性(非原子,复制)NSString*无_状态;
@属性(非原子的、不安全的、未维护的)UILabel*无状态标签;
@属性(非原子的、不安全的、未维护的)id委托;
@属性(非原子,复制)ICStatusViewControllerDoneCallbackBlock doneCallbackBlock;
@属性(非原子,复制)ICStatusViewControllerCancellBackblock CancellBackblock;
-(id)初始状态;
@结束

只需在
viewdiload:
ICStatusViewController的方法中为navigationcontroller添加这行设置黄色即可

[self.navigationController.navigationBar setTintColor:[UIColor yellowColor]];
还有像贝娄这样的形象

[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"yourImageName"] forBarMetrics:UIBarMetricsDefault];// write your image name like yellow image 

我希望这能帮助您……

您可以设置导航栏的色调,或者使用图像代替导航栏并隐藏导航
//  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
[self.navigationController.navigationBar setTintColor:[UIColor yellowColor]];
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"yourImageName"] forBarMetrics:UIBarMetricsDefault];// write your image name like yellow image 
navigationController.navigationBarHidden = YES;
self.settingsTableView = [[UITableView alloc] initWithFrame:rect
                                                      style:UITableViewStyleGrouped];
UIView *view = [[UIView alloc] initWithFrame:settingsTableView.frame];
view.backgroundColor = [UIColor redColor];
settingsTableView.backgroundView = view;