导航条相关内容

导航条相关内容

// 设置导航条titleViewUIView*v = [[UIViewalloc] initWithFrame:CGRectMake(2000,2000,100,100)];    v.backgroundColor= [UIColorgreenColor];self.navigationItem.titleView= v;// 导航条上的控件的位置由苹果自己决定,不能自己决定// 一般系统自带控件中子控件的位置一般由系统决定,我们只能决定尺寸.

// 设置导航条左边的内容//style 模式已经没用,可以随便选UIBarButtonItem*item = [[UIBarButtonItemalloc] initWithTitle:@"左边"style:UIBarButtonItemStyleDonetarget:selfaction:@selector(btnClick)];self.navigationItem.leftBarButtonItem= item;

// 设置导航条右边的内容// 加载图片UIImage*image = [UIImageimageNamed:@"navigationbar_friendsearch"];// 设置图片的渲染模式,返回没有被渲染的图片image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];UIBarButtonItem*rightItem = [[UIBarButtonItemalloc] initWithImage:image style:UIBarButtonItemStyleDonetarget:nilaction:nil];

// 如果想不要渲染,1.修改图片的渲染模式 2.通过代码self.navigationItem.rightBarButtonItem= rightItem;

iOS7默认导航控制器会对子控制器里的所有UIScrollView顶部都会添加额外的64滚动区域 // 不需要调整ScrollView滚动区域

self.automaticallyAdjustsScrollViewInsets=NO;

隐藏导航条

快速使用导航条背景透明

设置导航条透明

UIBarMetricsDefault必须填

传入一个空图片的image对象

[self.navigationController.navigationBarsetBackgroundImage:[[UIImagealloc] init] forBarMetrics:UIBarMetricsDefault];

清空导航条阴影线

[self.navigationController.navigationBarsetShadowImage:[[UIImagealloc] init]];

StoryBoard设置导航条隐藏

知识补充

要想让控件适应大小,可以调用sizetofit

你可能感兴趣的:(导航条相关内容)