测试已测试 | ✗ |
语言语言 | SwiftSwift |
许可证 | MIT |
发布最后发布 | 2017年11月 |
SwiftSwift 版本 | 4.0 |
SPM支持 SPM | ✗ |
由Francisco Soares维护。
FSOhanaAlert 是一个用 Swift 编写的 UIView 的子类,它为 Ohana - 家庭在一起创建简单的 Alert 视图。
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 文件。