0
當我向左滑動時如何滑出側邊菜單欄?當我點擊collectionView時它將如何自動滑出?我使用tableView和約束,我對這個約束的出口是rightMargin。如何滑出側邊菜單欄?在Swift中
import UIKit
import ViewPagerController
class OptionTableViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
@IBOutlet weak var rightMargin: NSLayoutConstraint!
@IBOutlet weak var optionTableView: UITableView!
let option = ["LOG IN","SIGN UP","EDIT PROFILE", "LOG OUT"]
let storyBoardId = ["LogInViewController","SignUpViewController","UserEditPageViewController", "None"]
override func viewDidLoad() {
super.viewDidLoad()
var appearance = ViewPagerControllerAppearance()
appearance.tabMenuAppearance.backgroundColor = UIColor.black
let screenWidth = UIScreen.main.bounds.width
rightMargin.constant = screenWidth
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
self.rightMargin.constant = 100
UIView.animate(withDuration: 0.3 , animations: {
self.view.layoutIfNeeded()
})
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return option.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = optionTableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
cell.textLabel?.text = option[indexPath.row]
cell.textLabel?.font = UIFont(name: "Arial", size: 10)
return cell
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if let logInViewController = storyboard?.instantiateViewController(withIdentifier: storyBoardId[indexPath.row]) {
navigationController?.pushViewController(logInViewController, animated: true)
}
}
}