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

    /** * @author 冰樱梦 * 时间:2018年下半年 * 题目:显示字符 *1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E F G H I J ...

  2. 通信编码解码 c11 实现 [ lua 专用版]

    #include <istream> #include <ostream> #include <iostream> #include <strstream&g ...

  3. xshell与虚拟机无法连接

    遇到xshell无法连接到虚拟机的情况,我大概总结为以下几种情况: 1.宿主机或虚拟机中的防火墙阻止了xshell的访问. 关闭宿主机和虚拟机中的防火墙,linux虚拟机中的防火墙关闭为 :servi ...

  4. python 实现汉诺塔问题

    代码如下: def hano(n,x,y,z): if n==1: print(x,"->",z) else: #将n-1个盘子从x->y hano(n-1,x,z,y ...

  5. Editplus格式化代码

    Editplus格式化代码插件(CSS,JS)今天在BlueIdea看到有人发了一篇名 为“让Editplus自动格式化css和js”的文章,看完后觉得写的很好,我也突然来了灵感,为什么不把前端开发常 ...

  6. python获取系统信息,

    1 操作系统系统综合信息cur_sysinfo=platform.uname()浏览器信息cur_browserinfo=self.driver.capabilities['version']浏览器新 ...

  7. c++之list学习

    #define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <list> using namespace std; ...

  8. javascript字符串处理方法

    字符串处理方法 1.字符串合并操作:“ + ”2.parseInt() 将数字字符串转化为整数3.parseFloat() 将数字字符串转化为小数4.split() 把一个字符串分隔成字符串组成的数组 ...

  9. 深入理解JavaScript中的函数操作——《JavaScript忍者秘籍》总结

    匿名函数 对于什么是匿名函数,这里就不做过多介绍了.我们需要知道的是,对于JavaScript而言,匿名函数是一个很重要且具有逻辑性的特性.通常,匿名函数的使用情况是:创建一个供以后使用的函数.简单的 ...

  10. J2EE之EJB

     EJB是sun的JavaEEserver端组件模型,最大的用处是部署分布式应用程序.EJB把使用java开发的server组件的部署和开发进行标准化. 凭借java跨平台的优势.用EJB技术部署的分 ...