iOS 画图 截图
2015-06-29 16:51
435 查看
//
// ViewController.m
// touchSCHEvent
//
// Created by tianshangrenjian on 15/6/29.
// Copyright (c) 2015年 tianshangrenjian. All rights reserved.
//
#import "ViewController.h"
#import "SCHView.h"
@interface
ViewController ()
@property (weak,
nonatomic) IBOutlet
SCHView *schView;
- (IBAction)clearPic:(id)sender;
@end
@implementation ViewController
- (void)viewDidLoad {
[super
viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
UIImagePickerController *vc;
vc.sourceType=UIImagePickerControllerSourceTypePhotoLibrary;
vc.cameraCaptureMode=UIImagePickerControllerCameraCaptureModePhoto;
}
- (void)didReceiveMemoryWarning {
[super
didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
鼠标点击的时候触发产生的事件
*/
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
}
//如果要截屏用self.view即可
- (IBAction)savepic:(id)sender {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2
* NSEC_PER_SEC)),
dispatch_get_main_queue(), ^{
UIGraphicsBeginImageContext(
self.schView.frame.size);//尺寸
CGContextRef ctx=UIGraphicsGetCurrentContext();
[self.view.layer
renderInContext:ctx];//图像层
UIImage *img=UIGraphicsGetImageFromCurrentImageContext();
UIImageWriteToSavedPhotosAlbum(img,
nil,
nil, nil);
UIGraphicsEndImageContext();
});
}
- (IBAction)undopic:(id)sender {
[self.schView
undo];
}
- (IBAction)clearPic:(id)sender {
[self.schView
clear];
}
@end
// ViewController.m
// touchSCHEvent
//
// Created by tianshangrenjian on 15/6/29.
// Copyright (c) 2015年 tianshangrenjian. All rights reserved.
//
#import "ViewController.h"
#import "SCHView.h"
@interface
ViewController ()
@property (weak,
nonatomic) IBOutlet
SCHView *schView;
- (IBAction)clearPic:(id)sender;
@end
@implementation ViewController
- (void)viewDidLoad {
[super
viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
UIImagePickerController *vc;
vc.sourceType=UIImagePickerControllerSourceTypePhotoLibrary;
vc.cameraCaptureMode=UIImagePickerControllerCameraCaptureModePhoto;
}
- (void)didReceiveMemoryWarning {
[super
didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
鼠标点击的时候触发产生的事件
*/
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
}
//如果要截屏用self.view即可
- (IBAction)savepic:(id)sender {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2
* NSEC_PER_SEC)),
dispatch_get_main_queue(), ^{
UIGraphicsBeginImageContext(
self.schView.frame.size);//尺寸
CGContextRef ctx=UIGraphicsGetCurrentContext();
[self.view.layer
renderInContext:ctx];//图像层
UIImage *img=UIGraphicsGetImageFromCurrentImageContext();
UIImageWriteToSavedPhotosAlbum(img,
nil,
nil, nil);
UIGraphicsEndImageContext();
});
}
- (IBAction)undopic:(id)sender {
[self.schView
undo];
}
- (IBAction)clearPic:(id)sender {
[self.schView
clear];
}
@end
相关文章推荐
- iOS 时间类的显示
- iOS学习之蓝牙4.0
- iOS开发之查找目录
- IOS根据两个经纬度计算相距距离
- iOS开发phonegap之消息推送
- <iOS>关于viewWithTag的一点说明
- iOS 画图 以及清空
- 【Ios开发】监听通讯录发生变化
- 深度解析~iOS应用程序~生命周期
- iOS画图 在控件中画图,并实现清理
- iOS页面间传值的方式(Delegate/NSNotification/Block/NSUserDefault/单例)
- iOS画图 在控件中画图
- ios 直角和圆角 并存
- 手势学习
- iOS打电话、发短信、发邮件功能开发
- iOS 纯代码适配iPhone6,6p
- IOS图像7之IOS图片、动画框架
- iOS didReceiveMemoryWarining
- IOS7 界面布局,导航条透明
- iOS 动态创建控件 并可以拖动控件