search

Home  >  Q&A  >  body text

objective-c - ios 如何朝一条直线方向移动

如题
我现在有一个正方形 起始点是它的中心点 末尾点是我收拖拽结束之后的那个点 这两点构成一条直线 如何让这个正方形的中心点始终沿着这条直线(延长线)运动呢?

大家讲道理大家讲道理2892 days ago406

reply all(4)I'll reply

  • ringa_lee

    ringa_lee2017-04-17 18:00:45

    Work out the position of the point to the edge of the screen from the start and end points, then move your square from the start point to the edge point of the screen.
    If you need to move it out of the screen, just move the edge point a little outside the screen.

    reply
    0
  • 迷茫

    迷茫2017-04-17 18:00:45

    If you want such an animation, just specify the beginning and end positions directly, no need to worry about the intermediate process

    reply
    0
  • 巴扎黑

    巴扎黑2017-04-17 18:00:45

    pseudocode

    [UIView animateDuration:1 animations:{
        view.center = targetPoint;
    }];

    reply
    0
  • PHP中文网

    PHP中文网2017-04-17 18:00:45

    This is a small demo I wrote. Can you understand it? https://github.com/KarmaChen/TestViewAnimation.git

    reply
    0
  • Cancelreply