Jelly 2.3.0

Jelly 2.3.0

测试已测试
Lang语言 SwiftSwift
许可证 MIT
发布最后发布2022年5月
SPM支持SPM

Sebastian Boldt维护。



Jelly 2.3.0

Jelly-Animators: Elegant Viewcontroller Animations in Swift

current version current version twitter handle Swift 4.2 compatible platform SPM-Compatible carthage support license

Jelly是一个用于.animate、非交互式和交互式.viewcontroller转换和呈现的库,重点是一个简单而灵活的API。
通过几行源代码,可以创建交互式UIzcze视图控制器转换和自定义可调整大小的UInze视图控制器呈现,而不必使用繁琐的UIKit Transitioning API。

使用原生
函数。
不要忘了保持Presentation

var slidePresentation = SlidePresentation(direction: .left)
let animator = Animator(presentation: slidePresentation)
animator.prepare(viewController: viewController)
present(viewController, animated: true, completion: nil)

  1. 对象
  2. Configure an Animator with the Presentation
  3. 函数。
  4. 调用原生
class ViewController : UIViewController {
    var animator: Jelly.Animator?
    override func viewDidLoad() {
        super.viewDidLoad()
        let viewController = YourViewController()
        let presentation = SlidePresentation(direction: .left)
        animator = Animator(presentation:presentation)
        animator?.prepare(presentedViewController: viewController)
        present(viewController, animated: true, completion: nil)
    }
}

保持强烈的💪参照

由于transitioningDelegate是弱引用,因此您需要在您要呈现的UIViewController内部或维护您呈现的中心对象中保持对Animator的强引用。

交互式过渡可以用于覆盖转换。如果转换是交互式的,则需要传递一个InteractionConfiguration对象到呈现中。

这里有三个参数扮演了重要的角色。首先是completionThreshold,它决定了动画完成的部分,即当用户完成的交互达到多少百分比时,动画会自动完成。第二个参数是实际交互类型。Jelly提供了.edge.canvas类型。在.edge转换中,用户必须从屏幕边缘执行手势。当使用.canvas类型时,配置了手势识别器,以便直接与呈现视图和被呈现视图交互,从而导致转换。最后一个参数是所谓的mode。使用模式,您可以限制交互到呈现或消失交互(默认值为[.present,.dismiss])。

let viewController = YourViewController()
let interaction = InteractionConfiguration(presentingViewController: self, completionThreshold: 0.5, dragMode: .edge, mode: .dismiss)
let presentation = SlidePresentation(direction: .right, interactionConfiguration: interaction)
let animator = Animator(presentation: presentation)
animator.prepare(presentedViewController: viewController)

Jelly 2.0还提供了一个名为LIVE UPDATE的新特性。使用Jelly的Live Update API,现在可以在视图控制器已经可见时更新alignmentsizemargin-guardscorner radius

这些是Animator提供的新的实时更新功能。

  • updateAlignment(alignment: PresentationAlignment, duration: Duration) - 覆盖和淡入淡出
  • updateVerticalAlignment(alignment: VerticalAlignment, duration: Duration) - 覆盖和淡入淡出
  • updateHorizontalAlignment(alignment: HorizontalAlignment, duration: Duration) - 覆盖和淡入淡出
  • updateSize(presentationSize: PresentationSize, duration: Duration) - 覆盖和淡入淡出
  • updateWidth(width: Size, duration: Duration) - 覆盖、淡入淡出和水平滑动
  • updateHeight(height: Size, duration: Duration) - 覆盖、淡入淡出和垂直滑动
  • updateMarginGuards(marginGuards: UIEdgeInsets, duration: Duration) - 覆盖和淡入淡出
  • updateCorners(radius: CGFloat, corners: CACornerMask, duration: Duration) - 覆盖、淡入淡出和滑动

对于不支持 presentationType 的情况,使用它们可能会引发异常。
例如:目前无法在幻灯片演示文稿中更新大小。

演示类型可以通过各种设置进行配置

  • 大小
  • 边距保护
  • 方向
  • 水平和垂直对齐
  • 暗淡和模糊的背景样式
  • 持续时间
  • 演示和消失曲线
  • 弹簧阻尼和速度
  • 角落规格 & 角落半径
  • 完成阈值
  • 交互式拖拽模式(边缘或平移)
  • 交互模式(演示、消失)
  • 视差(仅在幻灯片演示中可用)

每个组件的详细信息可以在 Jelly Wiki 中找到。

您的应用部署目标为 >= iOS 11.0

Jelly 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中

pod 'Jelly', '~> 2.2.2'

或使用 SPM

Sebastian Boldt, https://www.sebastianboldt.com

我是一名专注于 iOS 的移动软件架构师和开发者。热衷于创建令人惊叹的用户体验、设计美丽的用户界面,并编写可维护、结构化和面向最佳实践的代码。不断尝试提高技能并学习新技术。

current version

Jelly 遵循 MIT 许可证。详见 LICENSE 文件以获取更多信息。