美文网首页
手势 复习

手势 复习

作者: 雷仔 | 来源:发表于2016-02-24 00:26 被阅读16次

//在下面写出控件的基本属性

- (void)viewDidLoad {

[super viewDidLoad];

// Do any additional setup after loading the view.

self.view.backgroundColor = [UIColor whiteColor];

//建立一个图片视图(想要通过手势操作这个图片)

UIImageView *imaView = [[UIImageView alloc]initWithFrame:CGRectMake(20, 64, 300, 500)];

imaView.image = [UIImage imageNamed:@"S3.jpg"];

imaView.backgroundColor = [UIColor whiteColor];

[self.view addSubview:imaView];

[imaView release];

imaView.userInteractionEnabled = YES;

//轻拍手势 最常用到的手势

UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapclick:)];

[imaView addGestureRecognizer:tap];

[tap release];

//需要触碰几次

tap.numberOfTapsRequired = 3;

//需要几个手指触摸

tap.numberOfTouchesRequired = 2;

//其次重要的手势 长按

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

[imaView addGestureRecognizer:lp];

[lp release];

lp.numberOfTouchesRequired = 2;

lp.minimumPressDuration = 2;

}

//每个手势都需要用到其中的方法

//长按的方法

- (void)lpclick: (UILongPressGestureRecognizer *)lp

{

//如果这个状态是长按的情况下 输出"长按"

if (lp.state == UIGestureRecognizerStateBegan) {

NSLog(@"长按");

}

}

//轻拍的方法

- (void)tapclick: (UITapGestureRecognizer *)tap

{

NSLog(@"轻拍");

}

//以上两个手势最为常见

相关文章

  • 手势 复习

    //在下面写出控件的基本属性 - (void)viewDidLoad { [super viewDidLoad];...

  • 【18/30】手势的复习

    手势的“三、四、五” 一、三大原则 1、客观性原则 2、对比性原则 3、适量性原则 二、四大空间 1、肩部以上:能...

  • 手势

    点击手势 捏合手势 旋转手势 轻扫手势 拖拽手势 边缘平移手势 长按手势

  • iOS-手势详细参数说明

    敲击手势 长按手势 滑动手势 拖动手势 旋转手势 捏合手势 两种手势作用在同一个视图

  • 【iOS学习】——手势识别

    iOS 手势 手势需要开启用户交互 点击手势 单击手势 双击手势 添加 numberOfTapsRequired...

  • Swift - UIGestureRecognizer 各种手势

    1、点击手势2、拖动手势3、长按手势4、滑动手势5、捏合手势6、旋转手势 完整代码

  • iOS七种手势详解

    1、轻拍手势 2、捏合手势 3、旋转手势 4、平移手势 5、边缘轻扫手势 6、长按手势 7、轻扫手势 给image...

  • iOS手势总结

    1.轻拍手势 2.长按手势 3.轻扫手势 4.平移手势 5.捏合手势 6.旋转手势 7.边缘手势

  • iOS 手势

    修改时间: 2016-12-19修改次数: 0 手势传递 点击手势 捏合手势 轻扫手势 拖动手势 长按手势

  • iOS手势操作

    iOS手势有六种 手势类型: 手势状态: 创建View添加手势 1.轻点手势( UITapGestureRecog...

网友评论

      本文标题:手势 复习

      本文链接:https://www.haomeiwen.com/subject/wlfikttx.html