This release adds 3 great features. 💪💯
Thanks to @Durkslol, @TSCombine , @attheodo, @scandiumza for proposing new features. 🥇
NOTES
- Please see Backward compatibility section in this release note at first.
- I recommend to clean the framework with '⌘ + Shift + K' & rebuild it after you update it.
- Xcode's new build system doesn't rebuild it automatically so that there is a possible to use the old binary of this library.
New features
- Present it as a modality
- Intrinsic height(content fitting height) #57
- Show/Hide a panel without adding/removing it every time #64
New APIs
FloatingPanelController
show(animated:completion:)
hide(animated:completion:)
FloatingPanelLayout
FloatingPanelIntrinsicLayout
See "Use Intrinsic height layout" for detail,
FloatingPanelPosition
.hidden
Use cases
Present a floating panel as a Modality
let fpc = FloatingPanelController()
self.present(fpc, animated: true)
Add a floating panel to a container view.
let fpc = FloatingPanelController()
aContainerView.addSubview(fpc.view)
fpc.view.frame = aContainer.bounds // MUST
parent.addChild(fpc)
fpc.show(animated: true) {
self.didMove(toParent: self)
}
let fpc = FloatingPanelController()
fpc.hide(animated: true) {
// If needed
self.willMove(toParent: nil)
self.view.removeFromSuperview()
self.removeFromParent()
}
Backward compatibility
Please note 2 points for this release. These might make you change your code, but I believe and hope it would make this library better for you.
- View hierarchy change
.hidden
position
View hierarchy change
From this release, the view hierarchy managed FloatignPanelController
is changed.
FloatignPanelController.view
isn'tsurfaceView
anymore.- The
backdropView
isn't inserted to the parent view.
FloatignPanelController.view
is a root container view adding the surfaceView
and backdropView
.
.hidden
position
- The initial value of
FloatignPanelController.position
is.hidden
FloatignPanelController.position
is set to.hidden
after callinghide(animated:completion:)
as below.
fpc.hide(animated: true) {
print(fpc.position) // .hidden
}
- FloatingPanelLayout.insetFor(position:) might need the following change.
class ModalSecondLayout: FloatingPanelLayout {
func insetFor(position: FloatingPanelPosition) -> CGFloat? {
switch position {
case .full: return 18.0
case .half: return 262.0
case .tip: return 44.0
+ case .hidden: return nil
}
}
}