Transforms any view to sliding panel
Panel supports Anchor points, TabBarController and NavigationController, also it has basic TableView support.
Add following to your Podfile:
pod "CTSlidingUpPanel"
pod "CTSlidingUpPanel", '~> 0.1.1'
Make sure to build and clean the project:
import CTSlidingUpPanel
- Download this repository
- Copy files from lib folder to your project.
- Should be done.
You can view example project to better understand how stuff works.
But here are basic steps with Storyboard:
-
Drag any View(Or Container View) to the parent view. DO NOT give this view any constraints.
-
Create outlet of the view you wish to use as bottom panel
After that in your ViewController:
@IBOutlet weak var bottomView: UIView!
var bottomController:CTBottomSlideController?;
override func viewDidLoad() {
super.viewDidLoad()
//You can provide nil to tabController and navigationController
bottomController = CTBottomSlideController(parent: view, bottomView: bottomView,
tabController: self.tabBarController!,
navController: self.navigationController, visibleHeight: 64)
//0 is bottom and 1 is top. 0.5 would be center
bottomController?.setAnchorPoint(anchor: 0.7)
}
And done, view you provided to bottomView should slide up and down.
You can do same without Storyboards. Add new subview to your parent and then provide that subview to CTBottomSlideController. It is recomended that you don't give that subview any constraints.
In this case you should set: Top, Height and other constraints that you want(But don't set the bottom one) to the SlidingView and then use this initializer:
bottomController = CTBottomSlideController(topConstraint: slidingPanelTopConstraint,
heightConstraint: slidingPanelHeightConstraint,
parent: view,
bottomView: bottomView,
tabController: self.tabBarController!,
navController: self.navigationController,
visibleHeight: 64)
It is IMPORTANT that you don't set the bottom constraint of the sliding view or the sliding view will start resizing and that may affect performace.
- Take a Sliding View(View you provided to CTBottomSlideController) and wrap it in a generic UIView.
- Enable Clip to Bounds on the wrapper View
- Set any constraints you want to that wrapper view, place it anywhere resize it as much as you want.
- After that in CTBottomSlideController initializer provide that wrapper as a parrent view instead of root view.
//This is a wrapper view
@IBOutlet weak var parentView: UIView!
//In viewDidLoad() or something
parentView.clipsToBounds = true;
bottomController = CTBottomSlideController(parent: parentView/*instead of view*/, bottomView: bottomView,
tabController: self.tabBarController!,
navController: self.navigationController, visibleHeight: 64)
- Add this to your ViewController
class ViewController: UIViewController, CTBottomSlideDelegate
{...}
- Set viewcontroller as a delegate
bottomController?.delegate = self;
- Implement following methods
func didPanelCollapse();
func didPanelExpand();
func didPanelAnchor();
func didPanelMove(panelOffset: CGFloat);
Use this if you want sliding panel to slide up or down depending on TableViews offset:
func set(table:UITableView)
Use this if you want to specify how far up sliding panel should go
func setExpandedTopMargin(pixels: CGFloat)
Use these to programatically change panels state
func expandPanel();
func anchorPanel();
func closePanel();
func hidePanel();
func setSlideEnabled(bool) // Enable or disable sliding
Use this to check panels state
bottomController?.currentState
State can be
.collapsed
.expanded
.anchored
.hidden
Feel free to open up a new issue. I will try to respond as quick as I can