iOS: Simple Sliding Up Panel With TabBar.
There is only one way to install it to your project Just copy TSSlidingUpPanelManager.swift into your project
Cocopods coming soon
1- You need an UITabBarController in order to have UITabBar instance and also an instance of TSSlidingUpPanelManager
class SUTabBarController: UITabBarController, TSSlidingUpPanelStateDelegate {
@IBOutlet weak var suTabBar: UITabBar!
let slideUpPanelManager: TSSlidingUpPanelManager = TSSlidingUpPanelManager.with
.
.
.
}
2- Design your slidingUp view in your story board
3- You need UIView instance of it, Don't forget to set proper identifier for your slidingUp view controller
let slidingUpVC = (storyboard?.instantiateViewController(withIdentifier: "SUSlidingUp"))! as! SUSlidingUpVC
let slidingUpView = slidingUpVC.view
4- Initilize view
slideUpPanelManager.initPanelWithTabBar(inView: view, tabBar: suTabBar, slidingUpPanelView: slidingUpVC.view, slidingUpPanelHeaderSize: 49)
TSSldingUpPanelManager is a singleton manager which provides the following features
inView: UIView - Parent view, which sliding panel is going to be there, in my case it's my UITabBarController view
tabBar: UITabBar - UITabBar as it says
slidingUpPanelView: UIView - UIView of your sliding up panel view
slidingUpPanelHeaderSize: CGFloat - Size of the slidingUpPanel header
You can change slidingUpPanel state by it. toState: SLIDE_UP_PANEL_STATE
enum SLIDE_UP_PANEL_STATE {
case CLOSED
case OPENED
case DOCKED
}
return slideUpPanelState
If you want to scale the number, it's mostly used when user is dragging the slidingUpPanel and you want to adjust your views according to position of slidingUpPanel
You can change animation duration , default is 0.35
If it's true, tabbar won't be affected by animation or dragging , default is false
When SlidingUpPanel state is changed the following delegate is called
// slidingUpPanelNewState: new state
// yPos: Y poisition of the panel at new state
func slidingUpPanelStateChanged(slidingUpPanelNewState: SLIDE_UP_PANEL_STATE, yPos: CGFloat)
class SUTabBarController: ..., TSSlidingUpPanelStateDelegate {
...
override func viewDidLoad() {
...
slideUpPanelManager.slidingUpPanelStateDelegate = self
...
}
func slidingUpPanelStateChanged(slidingUpPanelNewState: SLIDE_UP_PANEL_STATE, yPos: CGFloat) {
...
}
}
These delegates are called when the UI Animation, which is responsbile to move the layouts (panel & tabbar), starts and finished
// withDuration: how long does the animation take
// slidingUpCurrentPanelState: at what state the animation is going to take place
// yPos: at what Y Position the animation is going to take place
func slidingUpPanelAnimationStart(withDuration: TimeInterval, slidingUpCurrentPanelState: SLIDE_UP_PANEL_STATE, yPos: CGFloat)
// withDuration: how long did it take
// slidingUpCurrentPanelState: at what state the animation is finished
// yPos: at what Y Position the animation is finished
func slidingUpPanelAnimationFinished(withDuration: TimeInterval, slidingUpCurrentPanelState: SLIDE_UP_PANEL_STATE, yPos: CGFloat)
class ViewController: UIViewController,...,TSSlidingUpPanelAnimationDelegate {
...
override func viewDidLoad() {
...
slideUpPanelManager.slidingUpPanelAnimationDelegate = self
...
}
func slidingUpPanelAnimationStart(withDuration: TimeInterval, slidingUpCurrentPanelState: SLIDE_UP_PANEL_STATE, yPos: CGFloat) {
...
}
func slidingUpPanelAnimationFinished(withDuration: TimeInterval, slidingUpCurrentPanelState: SLIDE_UP_PANEL_STATE, yPos: CGFloat) {
...
}
...
}
These delegates are called when user begins to drag the view
// when panel is began to be dragging by user
// startYPos at what Y Position user began to drag the panel
func slidingUpPanelStartDragging(startYPos: CGFloat)
// When panel in being dragged by user
// yPos: the center position of the panel
func slidingUpPanelDraggingVertically(yPos: CGFloat)
// When user is done by dragging
// Delta: if it's positive , it means panel was being dragged to the bottom of the screen
// if it's negative , it means panel was being dragged to the top of the screen
func slidingUpPanelDraggingFinished(delta: CGFloat)
class ViewController: UIViewController,...,TSSlidingUpPanelDraggingDelegate {
override func viewDidLoad() {
...
slideUpPanelManager.slidingUpPanelDraggingDelegate = self
...
}
func slidingUpPanelStartDragging(startYPos: CGFloat) {
...
}
func slidingUpPanelDraggingVertically(yPos: CGFloat) {
...
}
func slidingUpPanelDraggingFinished(delta: CGFloat) {
...
}
}
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D