開發(fā)繪圖、手勢綜合App注意點(diǎn)
手勢的一些注意事項(xiàng)
對于 UITapGestureRecognizer 來說我們一般需要知道該點(diǎn)擊手勢在屏幕中的位置 (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); //復(fù)位 [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圖形繪制、旋轉(zhuǎn)、長按、縮放、滑動等綜合手勢的一個 畫圖 項(xiàng)目
源碼地址:https://github.com/FantasticLBP/BlogDemos/tree/master/
以上就是本次我們分享的全部內(nèi)容,感謝你對腳本之家的支持。
相關(guān)文章
iOS應(yīng)用中UITableView左滑自定義選項(xiàng)及批量刪除的實(shí)現(xiàn)
這篇文章主要介紹了iOS應(yīng)用中UITableView左滑自定義選項(xiàng)及批量刪除的實(shí)現(xiàn),UITableView列表中即通訊錄左滑呼出選項(xiàng)的那種效果在刪除時能夠?qū)崿F(xiàn)多行刪除將更加方便,需要的朋友可以參考下2016-03-03IOS NSNotification 鍵盤遮擋問題的解決辦法
這篇文章主要介紹了IOS NSNotification 鍵盤遮擋問題的解決辦法的相關(guān)資料,希望通過本文能幫助到大家,解決這樣的問題,需要的朋友可以參考下2017-09-09實(shí)例解析iOS開發(fā)中系統(tǒng)音效以及自定義音效的應(yīng)用
這篇文章主要介紹了iOS開發(fā)中系統(tǒng)音效以及自定義音效的應(yīng)用,代碼基于傳統(tǒng)的Objective-C,需要的朋友可以參考下2015-10-10IOS開發(fā)代碼分享之設(shè)置UISearchBar的背景顏色
在項(xiàng)目開發(fā)中,我們經(jīng)常要用到UISearchBar,在網(wǎng)上看到了很多關(guān)于去除掉他背景色的方法,都已經(jīng)失效了,今天來分享一個正常使用的方法,希望能幫到大家2014-09-09iOS 實(shí)現(xiàn)多代理的方法及實(shí)例代碼
這篇文章主要介紹了iOS 實(shí)現(xiàn)多代理的方法及實(shí)例代碼的相關(guān)資料,需要的朋友可以參考下2016-10-10