成人午夜视频全免费观看高清-秋霞福利视频一区二区三区-国产精品久久久久电影小说-亚洲不卡区三一区三区一区

[IOS]圖片的旋轉(zhuǎn)和縮放

實(shí)現(xiàn)圖片的旋轉(zhuǎn)和縮放也是IOS開發(fā)中一個(gè)比較常見的技術(shù)點(diǎn),下面我們來一起學(xué)習(xí),這功能如何實(shí)現(xiàn)?

效果圖:

[IOS]圖片的旋轉(zhuǎn)和縮放
運(yùn)行的時(shí)候按住alt鍵能夠?qū)崿F(xiàn)圖片的伸縮

ViewController.h:

#import <UIKit/UIKit.h>  @interface ViewController : UIViewController <UIGestureRecognizerDelegate> {     float scale;     float prviousScale;  //放大倍數(shù)     float rotation;     float previousRotation; //旋轉(zhuǎn)角度 } @property (retain, nonatomic) IBOutlet UIImageView *otherImage;  @end 

ViewController.m:

#import "ViewController.h" #import "MyGestureRecongnizer.h"  //自定義手勢 @interface ViewController ()  @end  @implementation ViewController  - (void)viewDidLoad {     [super viewDidLoad];     prviousScale=1; 	     //縮放手勢     UIPinchGestureRecognizer *pin=[[UIPinchGestureRecognizer alloc]initWithTarget:self action:@selector(doPinch:)];     pin.delegate=self;     [self.otherImage addGestureRecognizer:pin];          //旋轉(zhuǎn)事件     UIRotationGestureRecognizer *rotaion=[[UIRotationGestureRecognizer alloc]initWithTarget:self action:@selector(doRotate:)];     rotaion.delegate =self;     [self.otherImage addGestureRecognizer:rotaion];               //添加自定義手勢(點(diǎn)擊到X大于200的地方相應(yīng))     MyGestureRecongnizer *my = [[MyGestureRecongnizer alloc] initWithTarget:self action:@selector(fun:)];     [self.view addGestureRecognizer:my];           } //自定義手勢觸發(fā)事件 -(void)fun:(MyGestureRecongnizer *)my {     NSLog(@"OK"); }  //允許同時(shí)調(diào)用兩個(gè)手勢,如果是no的話就只能調(diào)用一個(gè)手勢 -(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {     return YES; }  -(void)transfromImageView {     CGAffineTransform t=CGAffineTransformMakeScale(scale*prviousScale, scale*prviousScale);     t=CGAffineTransformRotate(t, rotation+previousRotation);     self.otherImage.transform=t; }  //縮放方法 -(void)doPinch:(UIPinchGestureRecognizer *)gesture {     scale=gesture.scale; //縮放倍數(shù)     [self transfromImageView];     if (gesture.state==UIGestureRecognizerStateEnded) {         prviousScale=scale*prviousScale;         scale=1;     } }  //旋轉(zhuǎn)方法 -(void)doRotate:(UIRotationGestureRecognizer *)gesture {     rotation=gesture.rotation; //旋轉(zhuǎn)角度     [self transfromImageView];     if (gesture.state==UIGestureRecognizerStateEnded) {         previousRotation=rotation+previousRotation;         rotation=0;     } }   - (void)dealloc {     [_otherImage release];     [super dealloc]; } @end 



新聞名稱:[IOS]圖片的旋轉(zhuǎn)和縮放
文章鏈接:http://jinyejixie.com/article10/pocjdo.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供企業(yè)建站、Google品牌網(wǎng)站設(shè)計(jì)、靜態(tài)網(wǎng)站、做網(wǎng)站、品牌網(wǎng)站制作

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

成都app開發(fā)公司
鄂伦春自治旗| 巴里| 玛曲县| 娄底市| 株洲县| 娱乐| 武夷山市| 方城县| 韶关市| 重庆市| 奇台县| 临潭县| 上林县| 方城县| 托克托县| 赣榆县| 陇南市| 大方县| 浦东新区| 瑞安市| 瑞丽市| 平舆县| 城市| 宣城市| 雷州市| 科技| 新乡市| 盐池县| 肃宁县| 崇义县| 六枝特区| 安达市| 辽中县| 奉贤区| 建平县| 余干县| 通州市| 木兰县| 盐山县| 旬阳县| 九龙坡区|