UIView animation in Swift 3
Apply animation to view is mandatory because by applying animation your app looks beautiful. You can set your view duration that how much time the animation will work and also set the delay time that your UIView will display on the screen, Here are some types of animation examples that you can apply to the view:-
- Change color of your view
1234UIView.animate(withDuration: 1, animations: {self.yourView.backgroundColor = .red} , completion : nil ) - Change size of your view
1234UIView.animate(withDuration: 1, animations: {self.yourView.frame.size.width += 20self.yourView.frame.size.height += 20} , completion : nil ) - Change position of your view
1234UIView.animate(withDuration: 1, animations: {self.yourView.frame.origin.x -= 50self.yourView.frame.origin.y -= 50} , completion : nil ) - Change position your view with auto reverse (mean like shaking your view)
12345678UIView.animate(withDuration: 1, animations: {self.yourView.frame.size.width += 20self.yourView.frame.size.height += 20}) { _ inUIView.animate(withDuration: 1, delay: 0.25, options: [.autoreverse, .repeat], animations: {self.yourView.frame.origin.y -= 50})}