ios 如何让导航栏上的左侧按钮靠左贴边显示,右侧按钮靠右贴边显示
2017-06-22 17:32
871 查看
// 配置右上角在线按钮
UIButton *onlineBtn = [[UIButton
alloc] initWithFrame:CGRectMake(0,
0, 100,
40)];
[onlineBtn addTarget:self
action:@selector(onlineAction:)
forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *rightBtn = [[UIBarButtonItem
alloc] initWithCustomView:onlineBtn];
UIBarButtonItem *space = [[UIBarButtonItem
alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace
target:nil
action:nil];
space.width = -20;//自己设定
// self.navigationItem.rightBarButtonItem = rightBtn;
self.navigationItem.rightBarButtonItems
= @[space, rightBtn];
leftItem = [[UIBarButtonItem alloc] initWithCustomView:leftButton];
UIBarButtonItem *space = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
space.width = -11;//自己设定
[self.navigationItem setLeftBarButtonItems:[NSArray arrayWithObjects:space,leftItem, nil]];
UIButton *onlineBtn = [[UIButton
alloc] initWithFrame:CGRectMake(0,
0, 100,
40)];
[onlineBtn addTarget:self
action:@selector(onlineAction:)
forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *rightBtn = [[UIBarButtonItem
alloc] initWithCustomView:onlineBtn];
UIBarButtonItem *space = [[UIBarButtonItem
alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace
target:nil
action:nil];
space.width = -20;//自己设定
// self.navigationItem.rightBarButtonItem = rightBtn;
self.navigationItem.rightBarButtonItems
= @[space, rightBtn];
leftItem = [[UIBarButtonItem alloc] initWithCustomView:leftButton];
UIBarButtonItem *space = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
space.width = -11;//自己设定
[self.navigationItem setLeftBarButtonItems:[NSArray arrayWithObjects:space,leftItem, nil]];
相关文章推荐
- IOS开发OC 如何将导航栏左侧系统自动生成的返回按钮的文字去掉,只保留小于号"<"图案
- 解决 ios7.0 以后自定义导航栏左边按钮靠右的问题
- iOS中自定义导航栏左边返回按钮和按钮不能靠左的问题
- iOS 自定义导航栏背景,左侧按钮,右侧按钮,及标题
- 实现左侧导航栏点击,右侧显示对应页面的布局
- iOS 11,关于隐藏导航栏左侧返回按钮的标题title
- iOS: 导航栏显示默认后退按钮
- (iOS开发)点击tabbar中的按钮显示首页,再如何跳转页面
- 自定义导航栏左边按钮的位置靠左问题,右边按钮的位置靠右的问题
- 设置按钮上的文字靠左靠右居中显示
- iOS 11,关于隐藏导航栏左侧返回按钮的标题title
- iOS UI之删除导航栏左侧按钮
- 解决 ios7.0 以后自定义导航栏左边按钮靠右的问题
- iOS 使button按钮的文本框靠左显示
- iOS隐藏系统导航栏左侧返回按钮上的标题
- RadioButton 左侧显示文字,右侧显示按钮时文字不靠边的问题解决
- iOS UIwebView如何去掉右侧、左侧的滚动条
- iOS开发笔记[17/50]:导航栏里的"Back"按钮显示不出来
- Swift在导航栏左侧或者右侧放置多个按钮
- iOS 11导航栏按钮不显示问题