I am trying to animate a UITableView
so that when the view appears, it slides up from the bottom of the screen. I have tried using loads of different methods from different questions on here, but no suggestions have worked for me.
What I have at the moment is this:
override func viewDidLoad() {
super.viewDidLoad()
menuTableView.layer.cornerRadius = 7
menuTableView.delegate = self
menuTableView.dataSource = self
view.addSubview(menuTableView)
menuTableView.frame.origin.y = menuTableView.frame.origin.y + menuTableView.frame.height
// Do any additional setup after loading the view.
}
override func viewDidAppear(animated: Bool) {
if (menuTableView.indexPathForSelectedRow() != nil) {
menuTableView.deselectRowAtIndexPath(menuTableView.indexPathForSelectedRow()!, animated: true)
}
UIView.animateWithDuration(10, animations: {
self.menuTableView.frame.origin.y - menuTableView.frame.height
})
}
Someone suggested adding the UITableView
as a subview, so I tried that, but it also doesn't work. The table just stays where it is.
Does anyone know a way that works in Swift?