Rideau 2.2.0

Rideau 2.2.0

muukiiJohn Estropia 维护。



Rideau 2.2.0

🎪Rideau

Rideau 是一种类似 Apple 应用程序(如 Maps、Shortcuts)的滑动界面。

🚀Rideau 正处于候选发布阶段!

概述

  • 💎支持多个快速定位点(例如,全部隐藏、半隐藏、全部显示,我们可以添加更多的快速定位点。)
  • 💎支持拖动时动画(例如,背景颜色变暗)
  • 💎支持处理 RideauView 内的 ScrollView 滚动
  • 💎支持根据 RideauView 的视图固有内容大小进行缩放
  • 交互式动画来自 UIViewPropertyAnimator,这使得它可实现中断动画且无瑕疵。(无法从 UIView.animate 获得)

RideauView 允许灵活设置快速定位点。《快速定位点》指的是拖动结束时可拖动视图“对齐”的指定偏移量。通常有 2 或 3 个快速定位点。


我们将常用到的对象

  • RideauView
  • RideauViewController
  • RideauSnapPoint

RideauView 是该库的核心对象。我们通常将我们自己的视图添加到 RideauView

RideauViewController 包含一个 RideauView。它允许我们将 RideauView 作为模态对话框呈现。

RideauSnapPoint 定义了内容视图停止的位置。

🔶需求

iOS 10.0+ Xcode 10.1+ Swift 4.2+

📱功能

  • 多个快速定位点
  • 平滑整合拖动和 UIScrollView 的滚动。
  • 自动跟踪 UIScrollView
  • 手动设置 UIScrollView 以跟踪
  • 在快速定位点之间使用 UIViewPropertyAnimator。

👨🏻‍💻 使用

内联显示

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)

多个SnapPoints

我们可以用RideauSnapPoint来定义SnapPoint。

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提供以下组件,可能会对我们有所帮助。

RideauMaskedCornerRoundedViewController

一个实现了遮罩圆角接口的容器视图控制器,具有一定的选项。

  • 更可定制
let targetViewController: YourViewController = ...
let toDisplayViewController = RideauMaskedCornerRoundedViewController(viewController: targetViewController)

let controller = RideauViewController(
  bodyViewController: RideauMaskedCornerRoundedViewController(viewController: target),
  ...

RideauMaskedCornerRoundedView

  • 更可定制

RideauThumbView

  • 更可定制

安装

CocoaPods

Rideau可以通过CocoaPods安装。要安装它,只需在Podfile中添加以下行

pod 'Rideau'

Carthage

对于Carthage,在你的Cartfile中添加以下内容

github "muukii/Rideau"

使用Rideau的项目

作者

贡献者

SwiftUI版

https://github.com/nerdsupremacist/Snap

许可协议

Rideau是在MIT许可下发布的。