【问题标题】:Drag UIView along bezier path沿贝塞尔路径拖动 UIView
【发布时间】:2012-10-14 18:31:10
【问题描述】:

我需要将 UIView 沿着贝塞尔路径从一个点拖到另一个点,最好的方法是什么?

【问题讨论】:

    标签: ios animation uiview


    【解决方案1】:

    这是将 uiview 从一个点拖动到另一个点的最简单方法。

    UIBezierPath *path  = [UIBezierPath bezierPath];
    [path moveToPoint:startingPoint];
    [path addLineToPoint:endPoint]; //you can use addCurveToPoint: , addArcToPoint:, etc
    
    CAKeyframeAnimation *pathAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
    pathAnimation.duration = 10.0;
    pathAnimation.path = path;
    pathAnimation.removeOnCompletion = NO ;
    [myView.layer addAnimation:pathAnimation forKey:@"pathAnimation"];
    

    【讨论】:

    • 这不是移动UIView,而是CALayer
    猜你喜欢
    • 2014-08-13
    • 2018-06-23
    • 1970-01-01
    • 2017-12-15
    • 1970-01-01
    • 1970-01-01
    • 2015-05-01
    • 1970-01-01
    相关资源
    最近更新 更多