Creating an app where a an image moves upon the press of a button(repeated 3 times). The image currently has a linear movement but what I need is a circular movement animation for it.
The image should start from the left of the screen, go towards top and then to the right of the screen so there are 3 points where the image stops. This has to be done with a circular animation.
enum TimeOfDay: String {
case Dimineata = "Dimineata"
case Pranz = "Pranz"
case Seara = "Seara"
}
class ViewController: UIViewController {
@IBOutlet weak var timeOfDayLabel: UILabel!
@IBOutlet weak var sunImage: UIImageView!
var timeOfDay = TimeOfDay.Dimineata
override func viewDidLoad() {
super.viewDidLoad()
}
@IBAction func didTapNext(_ sender: Any) {
switch timeOfDay {
case .Dimineata:
timeOfDay = .Pranz
sunImage.image = UIImage(named: "LunchSun")
UIView.animate(withDuration: 1) {
self.sunImage.frame = CGRect(x: self.view.center.x-50, y: 120, width: 100, height: 100)
}
case .Pranz:
timeOfDay = .Seara
sunImage.image = UIImage(named: "NightSun")
UIView.animate(withDuration: 1) {
self.sunImage.frame = CGRect(x: self.view.frame.width-50, y: 166, width: 100, height: 100)
}
default:
timeOfDay = .Dimineata
sunImage.image = UIImage(named: "NightSun")
UIView.animate(withDuration: 1) {
self.sunImage.frame = CGRect(x: self.view.frame.origin.x-50, y: 166, width: 100, height: 100)
}
}
timeOfDayLabel.text = timeOfDay.rawValue.uppercased()
}
}