I want to animate my UIPickerView after pressing the button. I already have coded my UIPickerView to be hidden on viewDidLoad and not hidden after pressing a button, but it does
1- Set hight to 216 (PickerView Standard).
2- Set leading an trailing to safe Area.
3- Set Bottom to "SuperViewBottom" as -216.
4- Make a IBOutlet from line 3 as NSLayoutConstraint optional.
and then:
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
bottom.constant = -216
}
@IBOutlet weak var bottom: NSLayoutConstraint!
-(IBAction)button:(id)sender
{
UIView.animate(withDuration: 0.2, delay: 0.0, options: .curveEaseIn, animations:
{
self.bottom.constant = 0
self.view.layoutIfNeeded()
}) { (AnimationComplete ) in }
}
override func touchesBegan(_ touches: Set, with event: UIEvent?) {
UIView.animate(withDuration: 0.2, delay: 0.0, options: .curveEaseIn, animations:
{
self.bottom.constant = -216
self.view.layoutIfNeeded()
}) { (AnimationComplete ) in }
}
}
it should working like Apple standard animation.
Good luck