Home>
Problem i am experiencing

I want to move the view as I slide the screen with my finger.

While the UIView of the above image is stopped, touchesMoved is called and keeps updating the coordinates.
Below is the code.

import UIKit
class ViewController: UIViewController {
    var imageView: UIImageView!
    override func viewDidLoad () {
        super.viewDidLoad ()
        let image = UIImage (named: "LogoARKit")
        let screenWidth = view.frame.width
        let screenHeight = view.frame.height
        imageView = UIImageView (image: image)
        imageView.frame.size.width = screenWidth/3
        imageView.frame.size.height = screenWidth/3
        imageView.center = CGPoint (x: screenWidth/2, y: screenHeight/2)
        view.addSubview (imageView)
    }
    override func touchesMoved (_ touches: Set<UITouch>, with event: UIEvent?) {
        let touch = touches.first!
        let location = touch.location (in: view)
        imageView.center = CGPoint (x: location.x, y: location.y)
    }
    override func didReceiveMemoryWarning () {
        super.didReceiveMemoryWarning ()
        // Dispose of any resources that can be recreated.
    }

}