Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/113.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何快速移动圆圈中的图像_Ios_Swift_Core Graphics - Fatal编程技术网

Ios 如何快速移动圆圈中的图像

Ios 如何快速移动圆圈中的图像,ios,swift,core-graphics,Ios,Swift,Core Graphics,有人能告诉我如何创建圆的路径并在其周围移动图像吗 我需要的是: 我发现了如何做圆的路径,但其余的我不知道怎么做。我是iOS开发新手 而且,我需要在打开页面时开始此操作 检查这段代码,objectToMove是从故事板到测试的UIView,这里我使用的是您的路径代码,但我添加了更多的半径 import UIKit class ViewController: UIViewController { @IBOutlet weak var objectToMove: UIView!

有人能告诉我如何创建圆的路径并在其周围移动图像吗

我需要的是:

我发现了如何做圆的路径,但其余的我不知道怎么做。我是iOS开发新手


而且,我需要在打开页面时开始此操作

检查这段代码,objectToMove是从故事板到测试的UIView,这里我使用的是您的路径代码,但我添加了更多的半径

import UIKit

class ViewController: UIViewController {
    @IBOutlet weak var objectToMove: UIView!

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }

    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: 100 - (100/2),y: 100 - (100/2)), radius:  CGFloat(100), startAngle: CGFloat(0), endAngle:CGFloat(M_PI * 2), clockwise: true)
        orbit.path = circlePath.CGPath
        orbit.duration = 4
        orbit.additive = true
        orbit.repeatCount = 100
        orbit.calculationMode = kCAAnimationPaced
        orbit.rotationMode = kCAAnimationRotateAuto

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

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


}

我希望这对您有所帮助,您需要什么?你需要动画90,然后呢?我想你需要的是在圆圈中移动你的所有视图我需要的第一个img将在2个img移动90º后移动其他90º,3,4个img在一个性能圆圈中移动相同?你也可以把你所有的子视图放在一个视图中并旋转?我只需要像上面一样移动调色板和卡车,我会想我如何解决这个问题。。。但是有人认为我如何做这个动作将从左边开始,因为它从右边开始使用
顺时针:false
而不是
顺时针:true
import UIKit

class ViewController: UIViewController {
    @IBOutlet weak var objectToMove: UIView!

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }

    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: 100 - (100/2),y: 100 - (100/2)), radius:  CGFloat(100), startAngle: CGFloat(0), endAngle:CGFloat(M_PI * 2), clockwise: true)
        orbit.path = circlePath.CGPath
        orbit.duration = 4
        orbit.additive = true
        orbit.repeatCount = 100
        orbit.calculationMode = kCAAnimationPaced
        orbit.rotationMode = kCAAnimationRotateAuto

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

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


}