使用 Swift 编写的 UIAlertView 替代品,具有现代的可链式 API 和高度可定制的 UI,灵感来自 SIAlertView 和 SweetAlert-iOS.
将 JLAlertView.swift
添加到您的项目中。
JLAlertView(title: "Default Style", message: "Standard Alert")
.addTextFieldWithConfigurationHandler({ (textField) in
textField.placeholder = "Username"
})
.addTextFieldWithConfigurationHandler({ (textField) in
textField.placeholder = "Password"
})
.addButttonWithTitle("Cancel", style: .Cancel, action: nil)
.addButttonWithTitle("OK", action:{(title, alert) in
let username = alert.textFields[0].text
let password = alert.textFields[1].text
print(username)
print(password)
})
.show()