开发绘图、手势综合App注意点
程序员文章站
2023-12-19 08:10:16
手势的一些注意事项
对于 uitapgesturerecognizer 来说我们一般需要知道该点击手势在屏幕中的位置 (locationinview:self)...
手势的一些注意事项
对于 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/
以上就是本次我们分享的全部内容,感谢你对的支持。