Create pull up view with multiple sticky points with scrollView supported.
- Multiple sticky points
- Only Support's Portrait
- Support's scrollView scroll connection (like AirBnb)
TWPullUpView is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'TWPullUpView'
import TWPullUpView
override func viewDidLoad() {
super.viewDidLoad()
let pullUpView = MyPullUpViewController()
pullUpView.stickyPoints = [.percent(0.3), .percent(0.6), .max]
pullUpView.addOn(self, initialStickyPoint: .percent(0.3), animated: true)
pullUpView.isPullUpScrollEnabled = true
// Remove View
pullUpView.removeView(animate: true)
}
class MyPullUpViewController: TWPullUpViewController {
}
// It get called before the view move to nearest sticky point
willMoveToPoint = { point in
}
// It get called after the view moved to the nearest sticky point
didMoveToPoint = { point in
}
// It get called when the user is panning the view
didChangePoint = { point in
}
// It get called when the user is panning and return's percentage of how much the view is opened.
// You can change the starting point of the percent by overriding 'startPercentFromPoint' the default is the min point in sticky array.
percentOfMinToMax = { percent in
}
class MyPullUpViewController: TWPullUpViewController {
private func setView() {
attachScrollView(tableView)
}
}
public struct TWPullUpOption {
/// Animation option to nearest sticky point when panning is ended
public var animationDuration: Double = 0.3
public var animationDamping: CGFloat = 1
public var animationSpringVelocity: CGFloat = 0.4
/// If view can pull up then max height. (When there is no scrollview inside)
public var overMaxHeight: Bool = true
/// If view can pull down then min Height
public var underMinHeight: Bool = true
/// Velocity of the panning to go to next sticky point
/// If it is 0 it will move to next point right away.
/// If it is CGFloat.infinity view will need to move more than half up or down to move to the next sticky point
/// Recommend to use between 1000 ~ 3000
public var moveToNextPointVelocity: CGFloat = 1500
}
class MyPullUpViewController: TWPullUpViewController {
override var option: TWPullUpOption {
return TWPullUpOption()
}
}
To run the example project, clone the repo, and run pod install
from the Example directory first.
TWPullUpView is available under the MIT license. See the LICENSE file for more info.