FSOhanaAlert 0.2.4

FSOhanaAlert 0.2.4

测试已测试
语言语言 SwiftSwift
许可证 MIT
发布最后发布2017年11月
SwiftSwift 版本4.0
SPM支持 SPM

Francisco Soares维护。



  • 作者:
  • Francisco Soares

FSOhanaAlert

概述

FSOhanaAlert 是一个用 Swift 编写的 UIView 的子类,它为 Ohana - 家庭在一起创建简单的 Alert 视图。

要求

  • iOS11

CocoaPods 安装

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

pod "FSOhanaAlert"

使用方法

import FSOhanaAlert

// Helper function that makes completion better
func completion<Result>(onResult: @escaping (Result) -> Void, onError: @escaping (Error) -> Void) -> ((Result?, Error?) -> Void) {
    return { (maybeResult, maybeError) in
        if let result = maybeResult {
            onResult(result)
        } else if let error = maybeError {
            onError(error)
        } else {
            onError(FSError.NoResultFound)
        }
    }
}

class ViewController: UIViewController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        let alertView = FSOhanaCustomAlert(frame: self.view.bounds)
        alertView.set(text: "Do you wish to take this activity?")
        alertView.set(image: #imageLiteral(resourceName: "icon_real"))
        
        alertView.set(completion: completion(
            onResult: { (result) in print("took")
                                    alertView.removeFromSuperview()
        },
            onError: { (error) in print("leave")
                                    alertView.removeFromSuperview()
        }), with: ["Cancel", "Take"])

        self.view.addSubview(alertView)
        self.view.bringSubview(toFront: alertView)
    }

作者

Francisco Soares

许可证

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