Reputation: 1960
Requirement:
What i have tried:
I have tried with tableview, scroll view but no luck. Finally want to try with collection view, can any one please help me out how to proceed with collection view. And in future do we get any complications if we use collection view.
Upvotes: 0
Views: 95
Reputation: 9503
StackView
CollectionView
TableView
Note: You can take both CollectionView
or TableView
but I prefer both different so that I don't need to put condition in delegates & datasource and I can manage easily. Choice is your's what you like to prefer.
Now your UI design looks like this
Set your datas in CollectionView
and TableView
as per your requirement.
To toggle left menu, just use below one line code on greenButton action.
@IBAction func btnToggle(_ sender: Any) {
colView.isHidden = !colView.isHidden
}
For simple animation
@IBAction func btnToggle(_ sender: Any) {
UIView.animate(withDuration: 0.3) {
self.colView.isHidden = !self.colView.isHidden
}
}
Output:
Edit
You can take stackView in scrollview and turn off colview, tblView scrolling. Check below :
Additional code work
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
colView.isScrollEnabled = false
tblView.isScrollEnabled = false
colView.reloadData()
tblView.reloadData()
scrollView.contentSize = CGSize(width: self.view.frame.width,
height: max(colView.contentSize.height, tblView.contentSize.height))
stackHeight.constant = scrollView.contentSize.height
}
Note : It may cause some unexpected output (can be / can not be), so you need to take care of it.
Output:
Upvotes: 1