Rideau 是一种抽屉式 UI,类似于 Apple 应用程序所使用的 UI。(例如,地图、快捷指令)
🚀 Rideau 正处于发布候选版本!
RideauView 允许灵活的吸附点。 “吸附点”指的是在拖动结束时,可拖动视图“吸附”到的指定偏移量。通常有 2 或 3 个吸附点。
我们常用的对象
RideauView 是此库中的核心对象。我们通常将自己的视图添加到 RideauView。
RideauViewController 包含一个 RideauView。它允许我们将 RideauView 作为模态对话框呈现。
RideauSnapPoint 定义内容视图停止的位置。
iOS 10.0+ Xcode 10.1+ Swift 4.2+
let rideauView = RideauView(frame: .zero) { (config) in
config.snapPoints = [.autoPointsFromBottom, .fraction(0.6), .fraction(1)]
}
let someView = ...
rideauView.containerView.set(bodyView: container.view, options: .strechDependsVisibleArea)
let targetViewController: YourViewController = ...
let controller = RideauViewController(
bodyViewController: targetViewController,
configuration: {
var config = RideauView.Configuration()
config.snapPoints = [.autoPointsFromBottom, .fraction(1)]
return config
}(),
initialSnapPoint: .autoPointsFromBottom
)
present(controller, animated: true, completion: nil)
我们可以使用 RideauSnapPoint 定义吸附点。
public enum RideauSnapPoint : Hashable {
case fraction(CGFloat)
case pointsFromTop(CGFloat)
case pointsFromBottom(CGFloat)
case autoPointsFromBottom
}
config.snapPoints = [.pointsFromBottom(200), .fraction(0.5), .fraction(0.8), .fraction(1)]
RideauContainerView 有两种调整所添加内容视图大小的方式。
RideauContainerView.ResizingOption
final class RideauContainerView : UIView {
public func set(bodyView: UIView, resizingOption: ResizingOption)
}
Rideau 提供了以下可能对我们有帮助的组件。
一个容器视图控制器,实现了蒙版圆角界面并具有一些选项。
let targetViewController: YourViewController = ...
let toDisplayViewController = RideauMaskedCornerRoundedViewController(viewController: targetViewController)
let controller = RideauViewController(
bodyViewController: RideauMaskedCornerRoundedViewController(viewController: target),
...
Rideau 可通过 CocoaPods 获得。要安装它,只需将以下行添加到您的 Podfile
pod 'Rideau'
对于 Carthage,将以下内容添加到您的 Cartfile
github "muukii/Rideau"
https://github.com/nerdsupremacist/Snap
Rideau 在 MIT 许可下发布。