iOS手势 清扫和长按和旋转

//

//  ViewController.m

//  swipe手势

//

//  Created by tianshangrenjian on 15/7/2.

//  Copyright © 2015 tianshangrenjian. All rights reserved.

//


#import "ViewController.h"


@interface ViewController ()

@property (weak, nonatomic) IBOutlet UIImageView *iconImage;

@property (assign, nonatomic) CGFloat xRotation;

@end


@implementation ViewController

//swip清扫

- (void)swipxx

{

    NSLog(@"swip清扫");

}

- (void)longPress

{

    NSLog(@"longpress");


}

- (void)rotationSwip

{

    self.xRotation+=M_PI_4;

    CGAffineTransform form=CGAffineTransformMakeRotation(self.xRotation);

    [self.iconImage setTransform:form];

   

    

}

- (void)rotationSwixpnew:(UIRotationGestureRecognizer *)gesture

{

    

    CGAffineTransform form=CGAffineTransformMakeRotation(gesture.rotation);

    [self.iconImage setTransform:form];

    

    

}


- (void)viewDidLoad {

    [super viewDidLoad];

    // Do any additional setup after loading the view, typically from a nib.

    self.iconImage.image=[UIImage imageNamed:@"IMG_0006.jpg"];

    self.xRotation=0;

    //旋转

    UIRotationGestureRecognizer *rotation=[[UIRotationGestureRecognizer alloc ] initWithTarget:self action:@selector(rotationSwixpnew:)];

    

    

    

    

    [self.iconImage addGestureRecognizer:rotation];

    

    

    //----长按屏幕

    UILongPressGestureRecognizer *longPress=[[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPress)];

    

    longPress.minimumPressDuration=2;

    

    [self.view addGestureRecognizer:longPress];

    

    //-------清扫

    

    UISwipeGestureRecognizer *swipe=[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipxx)];

    swipe.direction=UISwipeGestureRecognizerDirectionRight ;

    swipe.numberOfTouchesRequired=2;

    self.iconImage.userInteractionEnabled=YES;

    [self.iconImage addGestureRecognizer:swipe];

    

}


- (void)didReceiveMemoryWarning {

    [super didReceiveMemoryWarning];

    // Dispose of any resources that can be recreated.

}


@end


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值