Swift 3 si prega di aggiungere gli oggetti necessari come tableView
import UIKit
class SecondViewController: UIViewController,UITableViewDelegate,UITableViewDataSource {
@IBOutlet var tabl: UITableView!
var name = ["tony","abu"]
override func viewDidLoad() {
super.viewDidLoad()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return name.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = UITableViewCell()
cell.textLabel?.text = name[indexPath.row]
return cell
}
override func viewWillAppear(_ animated: Bool) {
tabl.center.x = self.view.frame.width/5
UIView.animate(withDuration: 1.0, delay: 0, usingSpringWithDamping: 1.0, initialSpringVelocity:0.45, options: [], animations: ({
self.tabl.center.x = self.view.frame.width/3
//self.buttonAction.center.x = self.view.frame.width/2
}), completion: nil)
}
}
fonte
2017-12-04 05:59:33
Come nell'obiettivo C. – Kevin
Non riesco a trovare nulla con il tipo di animazione che desidero. Voglio solo una semplice slide in o fade in. Non è un gioco OpenGL. – Benr783
Cerca i metodi animati di 'UIView'. Funzionano allo stesso modo in Swift come in Obj-C. –