IYSlideView 0.1.4

IYSlideView 0.1.4

测试已测试
语言语言 SwiftSwift
许可证 MIT
发布最新发布2016年10月
SwiftSwift 版本3.0
SPM支持 SPM

Ilnur Yagudin 维护。



IYSlideView

该库能做什么?

示例

要运行示例项目,请先克隆仓库,然后从示例目录运行 pod install。在示例项目中,您将看到带有不同手势的五个示例。

要求

  • iOS 9.1 及更高版本
  • Swift 3
  • Xcode 8.0

安装

安装分为两部分:Storyboard 中设置和代码中的设置

  1. 部分 - Storyboard 中设置

    1.1. 打开你的 Storyboard 文件,选择你的控制器,拖放一个空的 UIView。这个视图将是你滑动视图。

    1.2. 如果你想,在你的滑动视图中拖放一个 Button。在这个说明中,我们将使用按钮。

    1.3. 选择你创建的视图,然后在 Interface Builder 中点击 Identity Inspector 选项卡,在 Custom ClassModule 字段中输入 IYSlideView

    1.4. 然后,向你的空视图添加以下约束:Horizontal in containerSpace from Top,以及 WidthHeight

    1.5. 点击 Connections Inspector 选项卡,你会看到三个出口:dragButtomheightwidth。将它们连接到滑动视图和按钮的约束。

  2. 部分 - 代码中的设置

    2.1. 打开你的 ViewController 类,在 imports 中添加以下行

    import IYSlideView

    2.2. 现在,你需要实现 IYSlideViewProtocols。要做到这一点,请添加

    class <nameOfYourVc>: UIViewController, IYSlideViewProtocols {
    ....
    }

    2.3. 然后,你需要实现至少一个必需的协议方法

    func slideViewPresentViewController(_ containerView: UIView) {
    }

    2.4. 在你的 ViewController 中添加以下行以创建 Outlet 并从 Storyboard 中连接它们

    @IBOutlet weak var sliderView: IYSlideView!

    2.5. 在 VC 中的 viewDidLoad 方法中添加以下行

    sliderView.settings.dragDirection = .down //Drag direction is required
    sliderView.delegate = self //required

    2.6. 最后,在 slideViewPresentViewController 方法(我们之前实现的方法)中添加以下行

    let controller = self.storyboard?.instantiateViewController(withIdentifier: "   <PresentingViewControllerStoryboardID>")
    self.addChildViewController(controller!)
    controller?.view.frame = containerView.bounds
    containerView.addSubview(controller!.view)
    self.didMove(toParentViewController: self)

    注意:将 PresentingViewControllerStoryboardID 替换为你想在滑动视图中显示的 ViewControllerStoryboardID

结果

Cocoa Pods

IYSlideView 可以通过 CocoaPods 获得。要安装它,只需将以下行添加到您的 Podfile 中

pod "IYSlideView"

其他信息

更多示例,请克隆 Example 仓库并在 Xcode 中打开。您将看到 5 个不同的示例。

作者

Ilnur Yagudin,[email protected]

许可证

IYSlideView 在 MIT 许可下可用。有关更多信息,请参阅 LICENSE 文件。