画图清空画布_iOS画图,截图及清空

本文介绍了如何在iOS应用中实现画图、截图和清空画布的功能。通过创建UIImageView作为画布,监听触摸事件进行绘图,并使用UIButton分别触发清空和截图操作。在清空画布时,直接将_imageView的image设为nil,而截图则通过UIGraphicsBeginImageContext获取屏幕快照。
摘要由CSDN通过智能技术生成

1 #import "ViewController.h"

2 #import "SecondVC.h"

3

4

5 #define WIDTH [UIScreen mainScreen].bounds.size.width

6 #define HEIGHT [UIScreen mainScreen].bounds.size.height

7

8 @interfaceViewController ()9 {10 UIImageView *_canvasView;//画布

11 CGPoint _startPoint;//记录开始坐标

12

13 }14 @end

15

16 @implementationViewController17

18 - (void)viewDidLoad {19 [super viewDidLoad];20

21 _canvasView =[[UIImageView alloc] initWithFrame:self.view.bounds];22 [self.view addSubview:_canvasView];23

24 UIButton *clearBtn =[UIButton buttonWithType:UIButtonTypeCustom];25 clearBtn.frame = CGRectMake(50, 20, 100, 30);26 [clearBtn addTarget:self action:@selector(clearBtnClick) forControlEvents:UIControlEventTouchUpInside];27 [clearBtn setTitle:@"清空"forState:UIControlStateNormal];28 clearBtn.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值