zoukankan      html  css  js  c++  java
  • 关于手势-平移 旋转 缩放

      //平移

        UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(pan:)];

        [myView addGestureRecognizer:pan];

        //缩放

        UIPinchGestureRecognizer *pinch = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(pinch:)];

        [myView addGestureRecognizer:pinch];

        //旋转

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

        [myView addGestureRecognizer:rotation];

        

    }

     

    //旋转

    - (void)rotation:(UIRotationGestureRecognizer *)traget {

        UIView *myView = traget.view;

        myView.transform = CGAffineTransformMakeRotation(traget.rotation);

    }

     

    //平移

    - (void)pan:(UIPanGestureRecognizer *)traget {

        UIView *myView = traget.view;

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

        myView.center = CGPointMake(myView.center.x + point.x, myView.center.y

                                    + point.y);

        [traget setTranslation:CGPointZero inView:self.view];

    }

     

    //缩放

    - (void)pinch:(UIPinchGestureRecognizer *)traget {

        UIView *myView = traget.view;

        myView.transform = CGAffineTransformMakeScale(traget.scale, traget.scale);

    //    myView.transform = CGAffineTransformScale(myView.transform, traget.scale, traget.scale);

    //    traget.scale = 1;

    }

  • 相关阅读:
    【搜索】棋盘 luogu-3956
    【动态规划】石子合并 luogu-1880
    【动态规划】合唱队形 luogu-
    【模拟】报名签到 luogu-4445
    【排序+贪心】导弹拦截 luogu-1158
    【模拟】不高兴的津津
    【模拟】选数 luogu-1037
    「JOISC2020」建筑装饰 4
    「清华集训」小 Y 和恐怖的奴隶主
    「CF708E」Student's Camp
  • 原文地址:https://www.cnblogs.com/naizui/p/5211581.html
Copyright © 2011-2022 走看看