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];

    }

     

     

    祝您愉快开心 ^_^

  • 相关阅读:
    Catalan数
    C# & LINQ 对象克隆
    Rotate Image
    反转链表
    QtCreator调试程序时GDB崩溃
    Regular Expression Matching
    Wildcard Matching
    DFA与NFA
    Set Matrix Zeroes
    PCA原理
  • 原文地址:https://www.cnblogs.com/tianglin/p/3532447.html
Copyright © 2011-2022 走看看