截屏demo
实现思想。
将当前self.view renderIn 当前ImageContext
然后绘制。
demo结合 基于soclia发送微博
截屏DEMO2 //方法2
UIGetScreenImage方法 是apple的私有方法 有概率不让上架
UIImage *snapshot;
CGImageRef cgScreen = UIGetScreenImage();
if (cgScreen) {
snapshot = [UIImage imageWithCGImage:cgScreen];
CGImageRelease(cgScreen);
}
UIScreen *mainScreen = [UIScreen mainScreen];
CGSize size = [mainScreen bounds].size;
CGFloat scale = [mainScreen scale];
CGFloat screenWidth = size.width * scale;
CGFloat screenHeight = size.height * scale;
CGRect rect=CGRectMake(0, 0, screenWidth, screenHeight);
self.image = [UIImage imageWithCGImage:CGImageCreateWithImageInRect([snapshot CGImage], rect)];
//res就是截图后的UII
需要导入
#import <QuartzCore/QuartzCore.h>
QuartzCore.framework
//
// ViewController.m
// LrnShareSNSDemo
//
// Created by liu poolo on 12-10-22.
// Copyright (c) 2012年 liu poolo. All rights reserved.
//
#import "ViewController.h"
#import <Social/Social.h>
#import <QuartzCore/QuartzCore.h>
@interface ViewController ()
@property UIImage *shareImage;
@property NSString *shareText;
@end
@implementation ViewController
@synthesize shareImage=_shareImage;
- (void)viewDidLoad
{
[super viewDidLoad];
self.shareImage=[UIImage imageNamed:@"share_image.png"];
self.shareText=@"现在较为蛋疼的是 用ios6自带的social.framework 发出来的 在微博来源会显示是ios而不是iphoneX 而且如果默认输入字数如果超过了限制 他会不显示 略坑爹的说";
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)buttonPressed:(id)sender {
NSArray *activityItem=nil;
if (self.shareImage) {
activityItem=@[self.shareImage,self.shareText];
//这里顺序无关,但是只能一个是image ,一个是nssting
//如果是2个NNString的话就会导致 啥都不显示。
}else{
activityItem=@[self.shareText];
}
UIActivityViewController *aVC=[[UIActivityViewController alloc]initWithActivityItems:activityItem applicationActivities:nil];
[self presentViewController:aVC animated:YES completion:nil];
}
- (IBAction)screenShotPressed:(id)sender {
UIGraphicsBeginImageContext(self.view.bounds.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image=UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
self.shareImage=image;
}
@end
分享到:
相关推荐
这是我在学习ios的过程中写的一个demo,使用Quartz 2D技术对屏幕截图,并将图片保存到文件中
仿 IOS 截屏动画,demo 可直接复制运行看效果,详细文章可参看 https://blog.csdn.net/u012932409/article/details/99683806
ios NSTimer应用demo 。iphone6.1 测试通过。具体demo截图和说明在:http://blog.csdn.net/donny_zhang
简单的模仿网易彩票界面的搭建 以及一些简单功能的实现 内有截图 注释详细 希望将自己自学的一些小成果和大家分享一下
是研究ios屏幕共享时编制的demo,重点参考了如下两个开源项目: 1 http://www.gdcl.co.uk/2013/02/20/iOS-Video-Encoding.html (ios 上h.264硬编码,RTSP服务端) 2 https://github.com/coolstar/RecordMyScreen ...
iPhone6.1 测试成功。 同目录下有demo截屏 用UIimageView实现360度旋转效果。主要代码在:FVImageSequence.m
自定义拍照页 拍照后根据提示框的位置截图 截图完成后返回图片
前两年IOS应用源码-主要是用于毕业设计学习的。
ios pagecontrol例子,iphone6.1测试通过。简单翻页框架,用UIscrollView加载内容页,施行页数控制。具体说明和截图参照:http://blog.csdn.net/donny_zhang
ios demo 在一定范围随机选择。利用rand()来产生随机数。iphone6.1测试通过。具体demo截图和说明:http://blog.csdn.net/donny_zhang
gif太大,所以只传了一张图,要看原版的Demo请到github下载:https://github.com/fish-yan/GetImage
iOS-small-function 项目中会出现小需求,验证一下功能(Demo并非所有自己手写,项目中涉及到东西,根据DEMO定制了自己项目中): Demo 功能如下: 1.SSGestureLockView-手势登录 2.UITableView悬浮 3.BarrageRenderer-...
实现图片和界面的放大镜功能,在整个界面上移动手指,放大部分也随之移动。整个界面都有放大镜效果。iphone 6.1测试通过。 demo说明和截图:http://blog.csdn.net/donny_zhang
ios 一个不错的图片浏览分享框架demo 。iphone 6.1测试通过。框架适合图片浏览,并可以微博分享到新浪,腾讯,网易等(由于各个微博接口有调整,不一定能分享成功。只看框架,分享功能可以找最新的官方接口整合)。...
监控系统截屏处理,并添加截屏后自己的应用逻辑处理,上传资源为iOS源码Demo,可直接打开项目查看截屏后打印的log信息,以便参考
通过前段时间十来天的ios学习,前几天抽空完成了这个App,可能问题很多,希望大家谅解。 同时又什么代码的问题,希望大家给提出建议。 本程序是仿照Appstore上的一个应用来参考做的。 程序架构,客户端(ios)+服务端...
iOS xcode工程-截长图Demo xcode 工程,可以截长图,snapshot scroller
实现拍照、从相册选择图片并对图片进行截取的Demo
通过调取Js方法实现Unity WebGL 屏幕截屏(相机全屏)及下载成jpeg图片,demo文件测试时截图下载位置是浏览器默认下载路径,如要指定下载路径,打开浏览器设置的下载时询问下载地址即可。当前demo下载文件格式是jpg...
iPad5.1 测试成功 同目录下有demo截屏 卷边的翻书效果