本篇文章主要给大家详细讲述了在IOS开发绘图、手势综合App容易遇到的坑以及注意事项等内容,有兴趣的朋友参考下吧。
手势的一些注意事项
对于 UITapGestureRecognizer 来说我们一般需要知道该点击手势在屏幕中的位置 (locationInView:self)
对于 UIPanGestureRecognizer 来说我们一般需要知道我们的滑动手势移动了多少距离 (translationInView:pan)
-(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];
}
[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图形绘制、旋转、长按、缩放、滑动等综合手势的一个 画图 项目

源码地址:https://github.com/FantasticLBP/BlogDemos/tree/master/
以上就是本次我们分享的全部内容,感谢你对编程学习网的支持。
织梦狗教程
本文标题为:开发绘图、手势综合App注意点
基础教程推荐
猜你喜欢
- Android多返回栈技术 2023-04-15
- Android中的webview监听每次URL变化实例 2023-01-23
- Flutter手势密码的实现示例(附demo) 2023-04-11
- IOS 播放系统提示音使用总结(AudioToolbox) 2023-03-01
- iOS开发教程之XLForm的基本使用方法 2023-05-01
- android studio按钮监听的5种方法实例详解 2023-01-12
- Android开发使用RecyclerView添加点击事件实例详解 2023-06-15
- IOS应用内跳转系统设置相关界面的方法 2022-11-20
- 解决Android Studio突然不显示logcat日志的问题 2023-02-04
- Flutter绘图组件之CustomPaint使用详解 2023-05-12
