iOS截屏保存至相册
#pragma mark 截屏并保存至相册
-(void)screenShotsComplete:(void(^)(UIImage * img)) complete
{
CGSize imageSize = [[UIScreen mainScreen] bounds].size;
UIGraphicsBeginImageContextWithOptions(imageSize, NO, 0);
CGContextRef context = UIGraphicsGetCurrentContext();
for (UIWindow * window in [[UIApplication sharedApplication] windows]) {
if (![window respondsToSelector:@selector(screen)] || [window screen] == [UIScreen mainScreen]) {
CGContextSaveGState(context);
CGContextTranslateCTM(context, [window center].x, [window center].y);
CGContextConcatCTM(context, [window transform]);
CGContextTranslateCTM(context, -[window bounds].size.width*[[window layer] anchorPoint].x, -[window bounds].size.height*[[window layer] anchorPoint].y);
[[window layer] renderInContext:context];
CGContextRestoreGState(context);
}
}
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(image, self, nil, nil);
NSLog(@"Suceeded!");
if(complete){
complete(image);
}
}
//点击保存至相册后,出现动画效果
[self screenShotsComplete:^(UIImage *img) {
UIImageView * imgView=[[UIImageView alloc]initWithFrame:weakSelf.view.bounds];
imgView.image=img;
[weakSelf.view addSubview:imgView];
CGPoint center=CGPointMake(weakSelf.view.center.x, weakSelf.view.center.y-64);
[UIImageView animateWithDuration:1.0f animations:^{
imgView.width-=imgView.width;
imgView.height-=imgView.height;
imgView.alpha=0.0f;
imgView.center=center;
} completion:^(BOOL finished) {
[imgView removeFromSuperview];
btn.enabled=YES;
[HintInfoView showOnView:weakSelf.view hintTitle:@"保存成功!" hintFont:weakSelf.commonTitleFont];
}];
}];
};
iOS截屏保存至相册的更多相关文章
- IOS 截屏(保存到相册中)
@interface NJViewController () /** * 点击截屏按钮 */ - (IBAction)captureView:(UIButton *)sender; /** * 白色v ...
- Unity3d 截屏保存到相册,并且刷新相册
要做一个截图的功能,并且玩家可以在相册中看到. 做的时候遇到了三个问题: 1.unity自带的截图API,Application.CaptureScreenshot在Android上不生效 2.图片保 ...
- android截屏:保存一个view的内容为图片并存放到SD卡
项目中偶尔会用到截屏分享,于是就有了下面这个截屏的方法~ 下面得saveImage()方法就是保存当前Activity对应的屏幕所有内容的截屏保存. private void saveImage() ...
- iOS 截屏分享(包含状态栏与不包含状态栏)
iOS8以上的新方法PhotoKit 监听截图相册变化,取最后一张图片:http://www.hangge.com/blog/cache/detail_1515.html PhotoKit 获取本机相 ...
- ios截屏代码[转]
http://www.cnblogs.com/chenxiangxi/p/3547974.html 这位博主的连接中将ios自定义大小位置的截屏代码写的很不错,马上就能用的方法,对于只想马上用的程序员 ...
- iOS截屏代码
转载自:http://m.open-open.com/m/code/view/1420469506375 1.普通界面 /** *截图功能 */ -(void)screenShot{ UIGraphi ...
- iOS ----------将照片保存到相册
在使用前 请导入photos.framework 然后导入 #import <Photos/PHPhotoLibrary.h> #import <Photos/PHAssetCha ...
- JS实现网页选取截屏 保存+打印 功能(转)
源码地址: 1.1 确定截图选取范围 用户在开始截图后,需要在页面上选取一个截图范围,并且可以直观的看到,类似如下效果: image 我们的选取范围就是鼠标开始按下的那个点到鼠标拖动然后松开的那个点之 ...
- iOS 多张图片保存到相册问题(add multiple images to photo album)
不知道朋友们有木有做过多图保存到系统的相册这个需求,我在用`UIImageWriteToSavedPhotosAlbum`保存图片时候,在代理回调方`didFinishSavingWithError` ...
随机推荐
- permeation开篇
学习方法: To follow the path look to the master follow the master walk with the master see through the m ...
- 在Express中安装XTemplate
上一节讲了安装Express,并且生成了一个"microblog"的工程,我们的目标是在工程下安装XTemplate: 1.安装xtpl npm install xtpl xtem ...
- Eclipse格式化代码换行、删除空行
Java代码 Window-preference-Java-Code Style-Formatter|Edit...-Line Wrapping|Maximum line width: 修改一行最大长 ...
- Linux系统监控命令
1. uptime: 负载监控,w命令更好地显示当前登录用户数的信息 2.top: 相当于uptime,提供了负载平均值的快照 (1)第一行: up 48days: 系统运行时间 2 users: 当 ...
- 给Ubuntu 16.04更换更新源
给自家的Ubuntu下载软件速度有点慢,毕竟是从国外下载软件,就想更换到国内比较好的更新源(就是这些软件所在的服务器),一般直接百度Ubuntu更新源就能出来一大堆,这时候最好是找和自己Ubuntu版 ...
- GTK+基本图元的绘制
// main.c #include <gtk/gtk.h> static void draw_round_rectangle (cairo_t * cr, double x, doubl ...
- 前端基本知识(一):W3C标准&&冒泡事件,捕获事件,W3C DOM对象模型,对比分析
W3C标准是万维网联盟, 其他的可以参考万维网版本的更新内容 一.W3C标准 二.W3C DOM事件 三.冒泡事件 四.捕获事件 一.W3C标准 其实网页是由三分部组成:1.结构(structure) ...
- MVC - 云服务器部署
本章将和大家分享的是如果在云服务器上部署mvc,云服务器部署其实也不高大上,就和咋们在自己电脑上用iis发布部署站点一样,只是需要使用云解析把自己购买的域名解析到对应的自己的云服务器上,这些都是用的云 ...
- 微信小程序开发之http到https的转化
小程序从公布到现在已经过去好几个月了,本来从小程序发布出来就准备抱着微信的大腿进行一波小程序开发的,但是由于公司项目小程序暂时不支持,也就只能一直搁浅.过年过来偶然和朋友谈起小程序,觉的工作再忙也得找 ...
- 对Unity注入技术最简单的理解和应用
Unity注入技术,我决定最大的作用在于一个项目,尤其是WEB项目在更远其中一个类时,不需要重新生成,直接通过WEBCONFIG文件的修改就可以更改对应关系和功能,实验步骤如下: 1:新建一个接口IS ...