ios 关于自定义navigationItem,实现右侧多个按钮
废话不多说,直接正文,有时候我们想要在导航栏实现多个Item,所以就用到了UIToolBar。
navigationItem可以定义两个地方,rightBarButtonItem与leftBarButtonItem。
例如,我们要实现这个导航栏样式:
具体代码:
UIToolbar*tools=[[UIToolbar alloc]initWithFrame:CGRectMake(5, 0, 80, 39)];//解决出现的那条线tools.clipsToBounds = YES; //解决tools背景颜色的问题[tools setBackgroundImage:[UIImage new]forToolbarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];[tools setShadowImage:[UIImage new]forToolbarPosition:UIToolbarPositionAny]; //添加两个button NSMutableArray*buttons=[[NSMutableArray alloc]initWithCapacity:2]; UIBarButtonItem*button3=[[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"你的图片"] style: UIBarButtonItemStyleDone target:self action:@selector(press2)];UIBarButtonItem*button2=[[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"你的图片"] style: UIBarButtonItemStyleDone target:self action:@selector(press)];button3.tintColor=[UIColor whiteColor];button2.tintColor=[UIColor whiteColor]; [buttons addObject:button3];[buttons addObject:button2];[tools setItems:buttons animated:NO];UIBarButtonItem*btn=[[UIBarButtonItem alloc]initWithCustomView:tools];self.navigationItem.rightBarButtonItem=btn;
转载于:https://www.cnblogs.com/oldk/p/5207029.html
ios 关于自定义navigationItem,实现右侧多个按钮相关推荐
- uni-app自定义导航栏右侧做增加按钮并跳转链接
uni-app自定义导航栏右侧做增加按钮并跳转链接 uni-app 在页面上的导航栏右侧做一个增加的图标 并实现跳转 1. 先看效果图 2. 实现思路 使用阿里图标库的字体图标, 下载放入本地文件 p ...
- iOS关于自定义rightBarButtonItem
在常见iOS开发中,我们常遇到这样的需求,如下: 我们需要自定义导航栏右侧按钮,常见的自定义包装按钮如下: //设置rightItem; UIButton *btn = [UIButton butto ...
- IOS 自定义导航栏标题和返回按钮标题
IOS中自定义导航栏标题: UILabel *titleText = [[UILabel alloc] initWithFrame: CGRectMake(160, 0, 120, 50)]; tit ...
- android极光推送声音,【极光推送】iOS APNS 自定义铃声
IOS APNS自定义推送铃声 是推送给苹果服务器时 将 推送的 key = sound 的value = @"custom.xxx".自定义铃声支持几种固定的格式.本人只以.ca ...
- iOS UIFont自定义字体
1. 将字体文件导入工程(.ttf) 2. 打开Build Phases -> Copy Bundle Resources,确定字体文件已经添加 3. 编辑info.plist文件,添加Font ...
- iOS模仿安卓Material Design的涟漪动画按钮
首先来看看实现后的效果吧 实现思路 其实这个按钮的实现时分简单,我的思路是: - 用UIView + UITapGestureRecognizer 来模拟实现一个按钮的效果 - 记录每次手指点击的位置 ...
- html5视频播放自定义视频播放暂停,解决暂停按钮在视频画面中的问题
html5视频播放自定义视频播放暂停,解决暂停按钮在视频画面中的问题 一.视频播放方法 var myVideo = $("#videoPlayExecute");function ...
- 【第3版emWin教程】第55章 emWin6.x按钮Button控件自定义回调函数,实现各种按钮效果
教程不断更新中:链接 第55章 emWin6.x按钮Button控件自定义回调函数,实现各种按钮效果 本章节为大家讲解按钮控件自定义回调函数,通过其回调函数就可以实现各种按钮效果.这方面的 ...
- ABAP ALV OO 自定义Toolbar 和Command及listmenu按钮
ALV OO 自定义Toolbar 和Command及listmenu按钮 前言 OOALV容器 OOALV 工具栏 1.定义OO 对象及字段 2.OO ALV FIELDCAT 字段定义 3.定义类 ...
最新文章
- 解决Win7旗舰版开机后无线网络识别非常慢的问题
- pycharm安装python包_Pycharm使用教程(四)-安装python依赖包(非常详细,非常实用)...
- QT的QMutexLocker类的使用
- ORACLE查询闪回
- php堆是什么,PHP 堆与堆排序的详解
- JPA和Hibernate级联类型的初学者指南
- centos-7.2 node.js免编译安装
- 阿里P8架构师谈:分布式事务的解决方案,以及原理、总结
- android fragment学习4-底部布局扩展TabLayout
- 完全分布式安装Hadoop,Hive,Hbase,Hwi,Zookeeper
- robocopy 备份_使用Robocopy复制、备份文件夹
- UFO报表另存为Excel提示:可能没有正确安装Excel
- 使用matlab生成高斯滤波模板_matlab实现图像高斯滤波
- 0-50A集成式霍尔电流传感器应用案例分享
- 本文介绍在Wireshark网络协议分析仪中如果解密SSL和TLS流量
- android svg图片使用
- 2012年华为杯校园编程大赛决赛 类别:软件C/C++语言
- Redis的基本使用
- Python、Cython、CPython的简单对比
- 看完Alibaba“Java成长笔记”我懂了! 为什么阿里的程序员成长如此之快?