自定义右侧的一个按钮

 UIBarButtonItem *myButton = [[UIBarButtonItem alloc] initWithTitle:@"主页" style:UIBarButtonItemStyleBordered target:self action:@selector(clickEvent)];

 self.navigationItem.rightBarButtonItem = myButton;

自定义右侧多个按钮

 //两个按钮的父类view

 UIView *rightButtonView = [[UIView alloc] initWithFrame:CGRectMake(, , , )];

 //历史浏览按钮

 UIButton *historyBtn = [[UIButton alloc] initWithFrame:CGRectMake(, , , )];

 [rightButtonView addSubview:historyBtn];

 [historyBtn setImage:[UIImage imageNamed:@"button_history"] forState:UIControlStateNormal];

 [historyBtn addTarget:self action:@selector(historyBtnEvent) forControlEvents:UIControlEventTouchUpInside];

 #pragma mark >>>>>主页搜索按钮

 //主页搜索按钮

 UIButton *mainAndSearchBtn = [[UIButton alloc] initWithFrame:CGRectMake(, , , )];

 [rightButtonView addSubview:mainAndSearchBtn];

 [mainAndSearchBtn setImage:[UIImage imageNamed:@"button_filter-"] forState:UIControlStateNormal];

 [mainAndSearchBtn addTarget:self action:@selector(mainAndSearchBtnEvent) forControlEvents:UIControlEventTouchUpInside];

 //把右侧的两个按钮添加到rightBarButtonItem

 UIBarButtonItem *rightCunstomButtonView = [[UIBarButtonItem alloc] initWithCustomView:rightButtonView];

 self.navigationItem.rightBarButtonItem = rightCunstomButtonView;

转自:https://www.jianshu.com/p/901203a8a90e

iOS 自定义NavigationBar右侧按钮rightBarButtonItem的更多相关文章

  1. iOS 自定义NavigationBar右侧按钮rightBarButtonItem--button

    //两个按钮的父类view UIView *rightButtonView = [[UIView alloc] initWithFrame:CGRectMake(, , , )]; //历史浏览按钮 ...

  2. iOS自定义的UISwitch按钮

    UISwitch开关控件 开关代替了点选框.开关是到目前为止用起来最简单的控件,不过仍然可以作一定程度的定制化. 一.创建 UISwitch* mySwitch = [[ UISwitchalloc] ...

  3. iOS自定义NavigationBar

    日常开发中少不了用到UINavigationController,但是很多情况都要自定义NavigationBar.依稀记得自己刚开始也踩了好多坑,凑今天有空,就把想到的写下来.有时间了,考虑再把自定 ...

  4. 修改navigationbar右侧按钮离屏幕边缘位置

    先上代码 UIButton *settingBtn = [Utils creatCustomButtonWithFrame:CGRectMake(, , , ) btnTitle: titleColo ...

  5. iOS 自定义UINavigationController返回按钮

    主要代码如下: //自定义导航栏返回按钮 self.navigationItem.leftBarButtonItem = ({ //导航栏返回背景视图 UIView *view = [[UIView ...

  6. ios 自定义NavgationBar的按钮

    UIImage *btnimage = [UIImage imageNamed:@"about.png"]; UIButton *btn = [[UIButton alloc] i ...

  7. [iOS微博项目 - 1.5] - NavigationBar标题按钮

    A.NavigationBar标题按钮 1.需求 在“首页”的导航栏中部设置一个“首页”文字+箭头按钮 统一设置样式 根据实际文本长度调整宽度 消除系统自带的点击高亮效果 点击按钮,箭头上下颠倒 gi ...

  8. iOS 如何自定义NavigationBar的高度

    UINavigationBar的高度在苹果官方的SDK中是固定的44个点,但是实际项目中我们却有可能遇到这样的情况,如下图: 这样的一个UINavigationBar的高度达到了84个点,这就需要我们 ...

  9. iOS 自定义导航栏笔记

    一.UINavigationBar的结构 导航栏几乎是每个页面都会碰到的问题,一般两种处理方式:1.隐藏掉不显示 2.自定义 1. 添加导航栏 TestViewController * mainVC ...

随机推荐

  1. python虚拟环境mkvirtualenv使用

    安装virtualenvwrapper  pip install virtualenvwrapper   修改默认虚拟环境目录: 环境变量中新建: 变量名:WORKON_HOME 变量值:目录位置 ( ...

  2. CSS3 长度单位

    http://www.w3chtml.com/css3/units/length/vh.html https://www.html.cn/book/css/values/length/vh.htm . ...

  3. Kubernetes Controller执行框架解析

    毫无疑问,声明式API以及Controller机制是Kubernetes设计理念的基础.Controller不断从API Server同步资源对象的期望状态并且在资源对象的期望状态和实际运行状态之间进 ...

  4. 移动手机端通过PC转接实现标签打印的解决方案

    废话不多讲,由于种种原因项目上出现了移动手持录入标签信息通过pc端转接实现打印的需求,所以简单研究了一下,本来考虑使用webapi方式实现,但是发现这种方式调用打印机实现自动打印比较困难,所以转而求其 ...

  5. LeetCode.1037-有效的回旋镖(Valid Boomerang)

    这是小川的第387次更新,第416篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第248题(顺位题号是1037).回旋镖是一组各不相同且不在一条直线上的三个点.给出三个点 ...

  6. HtML5与CSS3基础

    HTML标签 1.<a></a> 超链接标签 属性 href:跳转页面的连接 name:实现定锚功能,跳转同一页面不同位置(例返回顶部) target: (self, pare ...

  7. selenium—用NoSuchElementException异常判断页面元素是否存在

    一.知识补充 1.find_element的一种使用方法: find_element(by=方法,value=值) 例如: find_element(by="id",value=& ...

  8. k8s-kubernetes-configmap存储

    存储 configMap configMap描述信息 ConfigMap功能在Kubernetes1.2版本中引入,许多应用程序会从配置文件.命令行参数或环境变量中读取配置信息. ConfigMap ...

  9. [转帖]虚拟内存探究 -- 第四篇:malloc, heap & the program break

    虚拟内存探究 -- 第四篇:malloc, heap & the program break http://blog.coderhuo.tech/2017/10/19/Virtual_Memo ...

  10. vue中Runtime-Compiler和Runtime-only的区别

    一.选择Runtime-Compiler和Runtime-only不同模式的时候main.js文件的区别    二.vue程序运行过程 1.解析: 第一步,当把vue模板template传给Vue实例 ...