UIWebView加上safari风格前进后退按钮(转)
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风格前进后退按钮(转)的更多相关文章
- 在Java web项目中防止用户注销后使用浏览器中的“后退”按钮返回注销前页面
一背景 公司安全整改, 要求:系统中对于关键业务操作应确保使用浏览器"后退"功能无法回到上一步操作界面. 提供:凭证提供所有被检查系统关键业务操作后回退视频,视频显示关键业务操作后 ...
- Android 自带后退按钮的使用
一.后退按钮有两种定义,分别是向上按钮和返回按钮:向上按钮:偏向于一种父子关系:返回按钮:反映的是一种前后关系 向上按钮:在清单文件中需要添加后退功能按钮的Activity中添加parentActiv ...
- JQuery Mobile入门——设置后退按钮文字(转)
http://www.tuicool.com/articles/AZnYVz JQuery Mobile入门——设置后退按钮文字 时间 2013-01-09 20:24:28 CSDN博客原文 h ...
- 浏览器后退按钮导致jquery动态添加的select option值丢失的解决方法
监控浏览器返回功能 判断浏览器返回功能 禁用浏览器的后退按钮 JS禁止浏览器后退键 http://volunteer521.iteye.com/blog/830522/ 浏览器返回功能 判断上一页面来 ...
- 【转】【译】【Win10】在你的程序标题栏中显示后退按钮
原文地址:http://www.sharpgis.net/post/2015/05/21/Displaying-a-backbutton-in-your-app-window 免责声明:这篇文章基于 ...
- 监听当点击微信等app的返回按钮或者浏览器的上一页或后退按钮的事件
在实际的应用中,我们常常需要实现在移动app和浏览器中点击返回.后退.上一页等按钮实现自己的关闭页面.调整到指定页面或执行一些其它操作的 需求,那在代码中怎样监听当点击微信.支付宝.百度糯米.百度钱包 ...
- javascript怎么禁用浏览器后退按钮
1. <script language="JavaScript"> javascript:window.history.forward(1); </scri ...
- Ubuntu FireFox的“后退”按钮与Backspace键
我们都知道,大部分的网页浏览器和窗口管理器的“后退”按钮是和Backspace键关联的,这样会极大的方便并加快我们浏览时的翻页速度(我一直是左手 放在键盘上按快捷键,右手鼠标的姿势找文件和看网页的,省 ...
- js-控制浏览器和移动端的后退按钮 . popstate
//控制浏览器和移动端的后退按钮 if (window.history && window.history.pushState) { $(window).on('popstate', ...
随机推荐
- 【斜率优化】BZOJ1096-[ZJOI2007]仓库建设
[题目大意] 有n个工厂编号分别为1-n,第i个仓库库存量为p[i],距离第1个仓库的距离为x[i](x[1]=0).在每一个工厂建立一个仓库费用为c[i],没有建立仓库的工厂只能往编号大于它的仓库运 ...
- 10.1(java学习笔记)JDBC基本操作(连接,执行SQL语句,获取结果集)
一.JDBC JDBC的全称是java database connection java数据库连接. 在java中需要对数据库进行一系列的操作,这时就需要使用JDBC. sun公司制定了关于数据库操作 ...
- (转)[Unity3D]计时器/Timer
http://blog.sina.com.cn/s/blog_5b6cb9500101aejs.html 项目中管理计时器太混乱难看了,用好听点的话来说就是代码不优雅. 想了下就随手简单写了个时间 ...
- maven-pom-properties
出处: http://blog.csdn.net/taiyangdao/article/details/52358083
- Linux下数组遍历
声明一个数组变量 直接赋值: array[]=”Zero” array[]=”One” array[]=”Two” declare声明: declare -a array 小括号空格法: array= ...
- Instant Run 的操作影响到了代码,导致Android App启动闪退的问题
转自yuhc163原文android启动应用java.lang.NoClassDefFoundError: Class not found using the boot class loader; n ...
- [转] C++ try catch() throw 异常处理
原文地址 其它很多程序员一样,本书的主人公阿愚也是在初学C++时,在C++的sample代码中与异常处理的编程方法初次邂逅的,如下: // Normal program statements . ...
- Spring Boot使用@Async实现异步调用
原文:http://blog.csdn.net/a286352250/article/details/53157822 项目GitHub地址 : https://github.com/FrameRes ...
- solr copyfield字段使用实践
1.使用场景 比如我们现在有一个文档,有title.author.area.keyword.link等字段.现在要把这个文档索引到 solr中,为了方便对author.area.keyword进行搜索 ...
- 长sql 语句拼接
长sql 语句拼接