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

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

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

  2021-03-28 我要评论
想了解开发绘图、手势综合App注意点的相关内容吗,在本文为您仔细讲解绘图、手势综合App注意事项的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:IOS,绘图,手势,下面大家一起来学习吧。

手势的一些注意事项

对于 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/

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

猜您喜欢

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们