//self.navigationItem.title = @"标题"
UIView*redView = [[UIViewalloc]initWithFrame:CGRectMake(0,0,140,40)]
redView.backgroundColor= [UIColorredColor]
UIView*greenView = [[UIViewalloc]initWithFrame:CGRectMake(20,5,100,30)]
greenView.backgroundColor= [UIColorgreenColor]
[redViewaddSubview:greenView]
self.navigationItem.titleView= redView
//右边
UIBarButtonItem*rightItem = [[UIBarButtonItemalloc]initWithTitle:@"个人信息"style:UIBarButtonItemStylePlaintarget:selfaction:@selector(goUserInfoVc:)]
UIBarButtonItem*rightItem2 = [[UIBarButtonItemalloc]initWithBarButtonSystemItem:UIBarButtonSystemItemCameratarget:nilaction:nil]
self.navigationItem.rightBarButtonItems=@[rightItem,rightItem2]
//左边
UIBarButtonItem*leftItem = [[UIBarButtonItemalloc]initWithBarButtonSystemItem:UIBarButtonSystemItemAddtarget:nilaction:nil]
//通过图片创建barButtonItem
//生成一张不受父视图tintColor影响的图片
UIImage*image = [[UIImageimageNamed:@"github_grayscale"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]
UIBarButtonItem*leftItem2 = [[UIBarButtonItemalloc]initWithImage:imagestyle:UIBarButtonItemStylePlaintarget:nilaction:nil]
self.navigationItem.leftBarButtonItems=@[leftItem,leftItem2]
//self.navigationController.navigationBar.backgroundColor = [UIColor greenColor]
//设置导航栏的背景色
//self.navigationController.navigationBar.barTintColor = [UIColor greenColor]
//设置导航栏的样式
/*
UIBarStyleDefault浅
UIBarStyleBlack深
UIBarStyleBlackTranslucent
*/
self.navigationController.navigationBar.barStyle=UIBarStyleDefault
//设置背景图片不透明
//self.navigationController.navigationBar.translucent = NO
//修改导航左右内容的颜色
self.navigationController.navigationBar.tintColor= [UIColorgrayColor]
//隐藏自带的背景图片
[self.navigationController.navigationBarsetBackgroundImage:[[UIImagealloc]init]forBarMetrics:UIBarMetricsDefault]
//隐藏阴影图片
[self.navigationController.navigationBarsetShadowImage:[[UIImagealloc]init]]
//设置导航的toolBar
//把toolBar显示出来
self.navigationController.toolbarHidden=NO
UIBarButtonItem*toolBarItem = [[UIBarButtonItemalloc]initWithBarButtonSystemItem:UIBarButtonSystemItemPlaytarget:nilaction:nil]
UIBarButtonItem*toolBarItem2 = [[UIBarButtonItemalloc]initWithBarButtonSystemItem:UIBarButtonSystemItemStoptarget:nilaction:nil]
UIBarButtonItem*toolBarItem3 = [[UIBarButtonItemalloc]initWithBarButtonSystemItem:UIBarButtonSystemItemEdittarget:nilaction:nil]
//创建木棍特效UIBarButtonItem样式Fixed
UIBarButtonItem*toolBarItem4 = [[UIBarButtonItemalloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpacetarget:nilaction:nil]
toolBarItem4.width=50
UIBarButtonItem*toolBarItem5 = [[UIBarButtonItemalloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpacetarget:nilaction:nil]
toolBarItem5.width=100
//创建d簧特效UIBarButtonItem样式Flexible
UIBarButtonItem*toolBarItem6 = [[UIBarButtonItemalloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpacetarget:nilaction:nil]
//50棍- Play - 100棍- Stop -d簧- Edit - 50棍
self.toolbarItems=@[toolBarItem4,toolBarItem, toolBarItem5,toolBarItem2, toolBarItem6,toolBarItem3,toolBarItem4]
附加:
[self.navigationControllersetNavigationBarHidden:!self.navigationController.navigationBarHiddenanimated:YES]
[self.navigationControllersetToolbarHidden:!self.navigationController.toolbarHiddenanimated:YES]
-(void)viewWillAppear:(BOOL)animated{[super viewWillAppear:animated]
CGRect rect = self.navigationController.navigationBar.frame
self.navigationController.navigationBar.frame = CGRectMake(rect.origin.x,rect.origin.y,rect.size.width,84)
}
-(void)viewWillDisappear:(BOOL)animated{
[super viewWillDisappear:animated]
CGRect rect = self.navigationController.navigationBar.frame
self.navigationController.navigationBar.frame = CGRectMake(rect.origin.x,rect.origin.y,rect.size.width,44)
ios6可以用上面的的方法,ios7需要自定义view设置好高度,添加到navigationController.navigationBar上
你可以这么写:
UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0,0,320,70)]
view.backgroundColor = [UIColor redColor]
[self.navigationController.navigationBar addSubview:view]
就可以了
提供一个思路给你AppDelegate中, 有个rootViewController
你应该把这个菜单加在rootViewController.view上面
这样的话, 无论你d出什么东西, 它都是显示在最上层的
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)