DJSemiModalViewController 0.1.4

DJSemiModalViewController 0.1.4

David Jonsén 维护。




  • David Jonsén

DJSemiModalViewController

DJSemiModalViewController 是一个半模态的展示对话框,它会随着添加内容而增长。DJSemiModalViewController 适用于 iPhone 和 iPad。DJSemiModalViewController 模仿默认的 NFC 弹出对话框的设计。

示例

要运行示例项目,首先克隆仓库,然后在示例目录中运行 pod install

安装

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

pod 'DJSemiModalViewController'

如何使用

@IBAction func buttonAction(_ sender: Any) {

    let controller = DJSemiModalViewController()
    
    controller.title = "Title"
    
    let label = UILabel()
    label.text = "An example label"
    label.textAlignment = .center
    controller.addArrangedSubview(view: label)

    controller.presentOn(presentingViewController: self, animated: true, onDismiss: { })
}

向内容 StackView 添加视图

public func addArrangedSubview(view: UIView)

public func addArrangedSubview(view: UIView, height: CGFloat)

public func insertArrangedSubview(view: UIView, at index: Int)

展示 ViewController

public func presentOn(presentingViewController: UIViewController, animated: Bool = true, onDismiss dismissHandler: ViewWillDismiss?)

设置

controller.automaticallyAdjustsContentHeight = true
  
controller.maxWidth = 420

controller.minHeight = 200

controller.titleLabel.font = UIFont.systemFont(ofSize: 22, weight: UIFont.Weight.bold)

controller.closeButton.setTitle("Done", for: .normal)

作者

David Jonsén

许可协议

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

待办事项

  • 使得关闭方法可开/关;关闭按钮,背景点击,拖动手势。

致谢

由 rawpixel.com 在 Unsplash 上提供的照片