SmartPopup 1.5.1

SmartPopup 1.5.1

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布最新发布2017年9月

Ricardo Koch维护。



  • Ricardo Koch

[![CI状态](http://img.shields.io/travis/Ricardo Koch/SmartPopup.svg?style=flat)](https://travis-ci.org/Ricardo Koch/SmartPopup)

用法

要运行示例项目,请克隆仓库,然后先从Example目录运行pod install

要求

安装

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

pod "SmartPopup"

作者

Ricardo Koch,[email protected]

许可证

SmartPopup受MIT许可证的保护。有关更多信息,请参阅LICENSE文件。

描述

Cocoapods组件,用于在iOS中轻松创建和管理UI对话框

使用方法

只需从任何地方访问SmartPopup单例即可显示令人惊叹的动画弹出窗口。

SmartPopup.instance().showWithTitle("Welcome", message: "Welcome to Smart Popups!", buttons: nil)

如果您想为模型定义按钮。

var btn1 = SmartPopupButton(text: "Close Me", andBlock: {
    (instance:String!) -> Void in
    //Button click callback (instance: id of the popup)
})

或者您可以直接在弹出窗口中创建它们。

SmartPopup.instance().showWithType(SmartPopupTypeImage, image: UIImage(named: "questionIcon"), title: "Question", message: "Do you want to save?", buttons:
    [
        SmartPopupButton(text: "Yes", andBlock: {
            (instance:String!) -> Void in 
        }),
        SmartPopupButton(text: "No", andBlock: {
            (instance:String!) -> Void in
        })
    ]
)

您有五种类型的弹出窗口可供选择:纯文本、带图像、带图像视图、带活动指示器和带有Xib的自定义弹出窗口。

自定义弹出窗口

自定义弹出窗口可以具有您想要的任何界面。它们可以完全自定义,因为它们使用IB和视图类构建。SmartPopup单例将仅为您管理这些弹出窗口的显示。要创建自定义SmartPopup用户界面,您必须首先创建Xib文件并设计您想要的内容。然后创建一个视图类并实现以下协议

SmartPopupViewProtocol

必须实现此协议,以便SmartPopup组件将您的视图理解为客户自定义弹出窗口。这是一个您可以遵循的示例实现

//#Method used to instantiate the view and sent as parameter to the SmartPopup singleton
class func createFromXib() -> SmartPopupViewProtocol! {

    let array = NSBundle.mainBundle().loadNibNamed("XibNameHere", owner: self, options: nil)

    if array?.count > 0 {
        if let dialog = array![0] as? SmartPopupViewProtocol {
            return dialog
        }
    }
    return nil
}

//#Called to pass arguments to customize the behavior of the class and UI
func setArgs(args: [AnyObject]!) {

    if args != nil && args.count > 0 {
        if let arg = args[0] as? String {
            self.title = arg
        }
    }
}

//#Used when the popup is going to be shown.
func willShowWithId(identifier: String!) {
    self.popupId = identifier
}

//#Used when the UI components are going to be presented in the screen. This is when you should configure views, create or customize.
func config() {
}