码迷,mamicode.com
首页 > 其他好文 > 详细

触摸UITouches

时间:2014-06-06 20:42:54      阅读:215      评论:0      收藏:0      [点我收藏+]

标签:c   a   int   set   type   ui   

 

// 一个完整的触摸过程:touchesBegan -> touchesMoved -> touchesEnded

 

/**

 *  触摸开始(手指刚碰到view)

 */

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event

{

//    event.type

    

    // 随机取一个对象

//    UITouch *touch = [touches anyObject];

//

//    NSLog(@"touchesBegan--%d", touches.count);

    

//    NSLog(@"%d", touch.tapCount);

}

 

/**

 *  触摸ing(手指在view上面挪来挪去)

 */

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event

{

    UITouch *touch = [touches anyObject];

    

    // 当前触摸点

    CGPoint current = [touch locationInView:self];

    // 上一个触摸点

    CGPoint previous = [touch previousLocationInView:self];

    

    // 修改当前view的位置(中点)

    CGPoint center = self.center;

    center.x += current.x - previous.x;

    center.y += current.y - previous.y;

    self.center = center;

}

 

/**

 *  触摸结束(手指离开view)

 */

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event

{

//    UITouch *touch = [touches anyObject];

//    NSLog(@"touchesEnded--%d", touches.count);

}

 

触摸UITouches,布布扣,bubuko.com

触摸UITouches

标签:c   a   int   set   type   ui   

原文地址:http://www.cnblogs.com/ZippoatiOS/p/3766113.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!