zoukankan      html  css  js  c++  java
  • touchesMoved 实现拖拽

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

    {

     

         UITouch *touch = [touches anyObject];// 某一个手指

        CGPoint currentPoint = [touch locationInView:self.superview]; // 自己相对于父视图的坐标

        CGPoint previousPoint = [touch previousLocationInView:self.superview];

        

        CGFloat dltX = currentPoint.x - previousPoint.x;

        CGFloat dltY = currentPoint.y - previousPoint.y;

        CGPoint center = self.center;    

        CGPoint newCenter = CGPointMake(center.x + dltX, center.y + dltY);    

        self.center = newCenter;

        

         self.backgroundColor = [UIColorcolorWithRed:(arc4random() % 256)/255.0green:(arc4random() % 256)/255.0blue:(arc4random() % 256)/255.0alpha:1.0];

    }

     

  • 相关阅读:
    [Effective C++]条款01:视C++为一个语言联邦
    DOTNET
    simulation
    掩码
    motorsimsrc
    Unprivileged User's Account
    LAN WAN
    calloc malloc realloc
    useradd
    change user ID and group ID
  • 原文地址:https://www.cnblogs.com/NatureZhang/p/3669937.html
Copyright © 2011-2022 走看看