iOS开发绘图、手势综合App注意点

2025-05-29 0 92

手势的一些注意事项

对于 UITapGestureRecognizer 来说我们一般需要知道该点击手势在屏幕中的位置 (locationInView:self)

对于 UIPanGestureRecognizer 来说我们一般需要知道我们的滑动手势移动了多少距离 (translationInView:pan)

?

1

2

3

4

5

6

7

8
-(void) pan: (UIPanGestureRecognizer * ) pan {

CGPoint transP = [pan translationInView: pan.view]; //$1 = (x = 0.73990527317289434, y = 0)

CGPoint pont1 = [pan locationInView: self]; //$2 = (x = 198.16665649414063, y = 342.33332824707031)

CGPoint pont2 = [pan locationInView: self.imageV]; //$3 = (x = 198.12057060663793, y = 342.61609831987914)

pan.view.transform = CGAffineTransformTranslate(pan.view.transform, transP.x, transP.y);

//复位

[pan setTranslation: CGPointZero inView: pan.view];

}

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15
[UIView animateWithDuration: 0.25 animations: ^ {

self.imageView.alpha = 0;

}completion: ^ (BOOL finished){

self.imageView.alpha = 1;

UIGraphicsBeginImageContextWithOptions(self.bounds.size, NO, 0);

CGContextRef ctx = UIGraphicsGetCurrentContext();

[self.layer renderInContext: ctx];

UIImage * imageGot = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

[self.imageView removeFromSuperview];

if (self.delegate && [self.delegate respondsToSelector: @selector(handleImageView: didOperatedImage: )]){

[self.delegate handleImageView: self didOperatedImage: imageGot];

}

}

];

接下来来一个iOS图形绘制、旋转、长按、缩放、滑动等综合手势的一个 画图 项目

iOS开发绘图、手势综合App注意点

源码地址:https://github.com/FantasticLBP/BlogDemos/tree/master/

以上就是本次我们分享的全部内容,感谢你对快网idc的支持。

收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。

快网idc优惠网 建站教程 iOS开发绘图、手势综合App注意点 https://www.kuaiidc.com/89700.html

相关文章

发表评论
暂无评论