I have an image and I need to move it in a straight line for example from (x, y) to (x1, y2).
And after moving how do I make the image disappear?
I tried to do this but I don´t know what to do next.
@IBOutlet weak var moveobj: UIImageView!
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
linePath.move(to: CGPoint(x: 100, y: 100))
linePath.addLine(to: CGPoint(x: 300, y: 300))
moveobj.layer .addAnimation(path, forKey: "path")
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
// Set the image view in the starting location
moveobj.frame = CGRect(x: 100, y: 100, width: /* some width */, height: /* some height */)
UIView.animate(withDuration: /* some duration */, animations: {
// Move image view to new location
self.moveobj.frame = CGRect(x: 300, y: 300, width: self.moveobj.frame.width, height: self.moveobj.frame.height)
}) { (finished) in
// Animation completed; hide the image view
self.moveobj.isHidden = true
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.