今天在写程序内打开网页的功能,写工具条的时候发现系统图标里面竟然没有后退按钮,,由于我这个是静态库工程,不可能自己弄张图上去,不然使用本库的时候还得附上图片,经过一下午的搜索,终于找到个比较靠谱的,这哥们硬是用代码给画出来个箭头了(话说如果是其他不规则的图形要咋办呢?),还是google管用啊,baidu非常非常非常。。。垃圾。

Code Example: Drawing the iPhone Back Button(转载)

Recently, I had need to provide a back button similar to the one used in Mobile Safari for a consulting project.

Many of the buttons used in the built-in iPhone applications are made available via the SDK with built in button types and graphics. Unfortunately, the back button is not one of these.

Because I needed to display the toolbar button from inside a static library which can not include images, I had to render the back arrow directly in code.

Since this was a bit time consuming, I thought I would share in hopes that it saves someone else a little bit of time.

- (CGContextRef)createContext
{
// create the bitmap context
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef context = CGBitmapContextCreate(nil,27,27,8,0,
colorSpace,kCGImageAlphaPremultipliedLast);
CFRelease(colorSpace);
return context;
}
- (CGImageRef)createBackArrowImageRef
{
CGContextRef context = [self createContext];
// set the fill color
CGColorRef fillColor = [[UIColor blackColor] CGColor];
CGContextSetFillColor(context, CGColorGetComponents(fillColor));
CGContextBeginPath(context);
CGContextMoveToPoint(context, 8.0f, 13.0f);
CGContextAddLineToPoint(context, 24.0f, 4.0f);
CGContextAddLineToPoint(context, 24.0f, 22.0f);
CGContextClosePath(context);
CGContextFillPath(context);
// convert the context into a CGImageRef
CGImageRef image = CGBitmapContextCreateImage(context);
CGContextRelease(context);
return image;
}
- (UIBarButtonItem *)backButton
{
CGImageRef theCGImage = [self createBackArrowImageRef];
UIImage *backImage = [[UIImage alloc] initWithCGImage:theCGImage];
CGImageRelease(theCGImage);
UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithImage:backImage
style:UIBarButtonItemStylePlain
target:self.webView
action:@selector(goBack)];
[backImage release], backImage = nil;
return [backButton autorelease];
}
 

UIWebView加上safari风格前进后退按钮(转)的更多相关文章

  1. 在Java web项目中防止用户注销后使用浏览器中的“后退”按钮返回注销前页面

    一背景 公司安全整改, 要求:系统中对于关键业务操作应确保使用浏览器"后退"功能无法回到上一步操作界面. 提供:凭证提供所有被检查系统关键业务操作后回退视频,视频显示关键业务操作后 ...

  2. Android 自带后退按钮的使用

    一.后退按钮有两种定义,分别是向上按钮和返回按钮:向上按钮:偏向于一种父子关系:返回按钮:反映的是一种前后关系 向上按钮:在清单文件中需要添加后退功能按钮的Activity中添加parentActiv ...

  3. JQuery Mobile入门——设置后退按钮文字(转)

    http://www.tuicool.com/articles/AZnYVz JQuery Mobile入门——设置后退按钮文字 时间 2013-01-09 20:24:28  CSDN博客原文  h ...

  4. 浏览器后退按钮导致jquery动态添加的select option值丢失的解决方法

    监控浏览器返回功能 判断浏览器返回功能 禁用浏览器的后退按钮 JS禁止浏览器后退键 http://volunteer521.iteye.com/blog/830522/ 浏览器返回功能 判断上一页面来 ...

  5. 【转】【译】【Win10】在你的程序标题栏中显示后退按钮

    原文地址:http://www.sharpgis.net/post/2015/05/21/Displaying-a-backbutton-in-your-app-window 免责声明:这篇文章基于 ...

  6. 监听当点击微信等app的返回按钮或者浏览器的上一页或后退按钮的事件

    在实际的应用中,我们常常需要实现在移动app和浏览器中点击返回.后退.上一页等按钮实现自己的关闭页面.调整到指定页面或执行一些其它操作的 需求,那在代码中怎样监听当点击微信.支付宝.百度糯米.百度钱包 ...

  7. javascript怎么禁用浏览器后退按钮

    1. <script language="JavaScript">    javascript:window.history.forward(1); </scri ...

  8. Ubuntu FireFox的“后退”按钮与Backspace键

    我们都知道,大部分的网页浏览器和窗口管理器的“后退”按钮是和Backspace键关联的,这样会极大的方便并加快我们浏览时的翻页速度(我一直是左手 放在键盘上按快捷键,右手鼠标的姿势找文件和看网页的,省 ...

  9. js-控制浏览器和移动端的后退按钮 . popstate

    //控制浏览器和移动端的后退按钮 if (window.history && window.history.pushState) { $(window).on('popstate', ...

随机推荐

  1. 1.1(Spring MVC学习笔记)初识SpringMVC及SpringMVC流程

    一.Spring MVC Spring MVC是Spring提供的一个实现了web MVC设计模式的轻量级Web框架. Spring优点:网上有,此处不复述. 二.第一个Spring MVC 2.1首 ...

  2. 重写规则为什么要options +followsymlinks

    重写规则为什么要options +followsymlinks Web服务器的Apache安装编译成功mod_rewrite编译成模块,但当我在网站根目录下放了一个.htaccess配置文件,却得到了 ...

  3. js之对象(经典)

    一.对象的定义: 对象是JavaScript的一个基本数据类型,是一种复合值,它将很多值(原始值或者其他对象)聚合在一起,可通过名字访问这些值.即属性的无序集合. 二.对象的创建(多种方法) 1.对象 ...

  4. getopt使用

    参考: http://www.gnu.org/software/libc/manual/html_node/Example-of-Getopt.html http://en.wikipedia.org ...

  5. Node.js 连接mySQL程序

    环境:Oracle Enterprise Linux R5U7 安装mySQL 关于离线安装,下次在尝试,目前先来在线安装,过程如下: $ rpm -qa | grep -i mysql $ wget ...

  6. 面试题:判断两个字符串是否互为回环变位(Circular Rotaion)

    题干:   如果字符串 s 中的字符循环移动任意位置之后能够得到另一个字符串 t,那么 s 就被称为 t 的回环变位(circular rotation).   例如,ACTGACG 就是 TGACG ...

  7. 《深入理解Java虚拟机》笔记2

    都知道Java对内存是自动垃圾回收的,什么样的内存是可以回收的? 这个问题是值得思考的. 对象已死的判定方法有两种: (1)引用计数器法 给对象添加一个引用计数器,有一个地方用到此对象,计数器加一. ...

  8. How to simplify a PHP code with the help of the façade pattern?

    原文:https://phpenthusiast.com/blog/simplify-your-php-code-with-facade-class ------------------------- ...

  9. 2014ACM/ICPC亚洲区域赛牡丹江站现场赛-A ( ZOJ 3819 ) Average Score

    Average Score Time Limit: 2 Seconds      Memory Limit: 65536 KB Bob is a freshman in Marjar Universi ...

  10. knowledgeroot 配置

    首先下载 KnowledgeRoot 的安装包,就是一个压缩文件,解压缩后放到 WebRoot 下面 在浏览器中打开网站,自动提示进行安装,安装的过程很简单,安装结束后即可以使用. 安装包创建的数据库 ...