zoukankan      html  css  js  c++  java
  • UIPanGestureRecognizer下方法

    - (IBAction)handlePan:(UIPanGestureRecognizer *)sender

    {

        // translationInView: 滑动的偏移量

        CGPoint point = [sender translationInView:self.view];

        // locationInView: 手势在self.view中的位置 // 此方法属于UIGestureRecognizer

        CGPoint point1 = [sender locationInView:self.view];

        NSLog(@"translation:%@ location:%@",NSStringFromCGPoint(point), NSStringFromCGPoint(point1));

        sender.view.center = CGPointMake(sender.view.center.x + point.x,

                                         sender.view.center.y + point.y);

        // 这句话非常重要,拖动的时候是一直递增的,每次都得清零才不至于出视图外面

        [sender setTranslation:CGPointZeroinView:self.view];

    }

     

     

    祝您愉快开心 ^_^

  • 相关阅读:
    JS 异步编程
    JS XMLHttpRequest
    JS 日期
    JS DOM
    JS 异常处理
    JS BOM
    JS 正则表达式
    JS 面向对象
    (22)python PhantomJS
    HDU1698 线段树(区间更新区间查询)
  • 原文地址:https://www.cnblogs.com/tianglin/p/3532447.html
Copyright © 2011-2022 走看看