快速的直线路径

时间:2016-10-11 10:07:35

标签: swift

我需要帮助我有这个代码这是做圆形路径但我需要的是直线我尝试这样做但不成功。

override func viewDidAppear(animated: Bool) {



    super.viewDidAppear(animated)

    let orbit = CAKeyframeAnimation(keyPath: "position")
    var affineTransform = CGAffineTransformMakeRotation(0.0)
    affineTransform = CGAffineTransformRotate(affineTransform, CGFloat(M_PI))
    let circlePath = UIBezierPath(arcCenter: CGPoint(x: 150 - (100/2),y: 150 - (100/2)), radius:  CGFloat(150), startAngle: CGFloat(0), endAngle:CGFloat(M_PI * 2), clockwise: true)

    orbit.circlePath = path.CGPath
    orbit.duration = 8
    orbit.additive = true
    orbit.repeatCount = 0.25
    orbit.calculationMode = kCAAnimationPaced
    orbit.rotationMode = kCAAnimationRotateAuto

    moveobj.layer .addAnimation(orbit, forKey: "orbit")
}

更多一个问题如何在完成移动后消失。

由于

1 个答案:

答案 0 :(得分:0)

您可以使用CAShapeLayer轻松完成此操作。

var intervals = [];
//
//Load each widget
//
    @foreach (var widget in Model.Widgets.OrderBy(p => p.OrderSequence).ThenBy(p => p.Title).ToList())
{
    @:loadWidget("@widget.WidgetId", "@widget.AjaxUrl");
    if (widget.RefreshSeconds > 0)
    {
        @:intervals.push(setupWidgetAutoRefresh("@widget.WidgetId", "@widget.AjaxUrl", @widget.RefreshSeconds));
    }
}

首先,创建一个CAShapeLayer。 其次,创建一个UIBezierPath来定义行的路径。 第三,将贝塞尔曲线路径移动到起点。 第四,添加贝塞尔曲线路径的终点。 第五,将贝塞尔曲线路径应用于CAShapeLayer。 第六,应用笔触颜色,以便在将其添加为子图层时可以看到该线条。 最后,添加它是视图的子层。

相关问题