<分区>
我必须使用 Swift 语言以编程方式在我的应用程序中实现自定义警报。我尝试使用一些第三方库“SCLAlertView”来实现,但无法从中理解,我需要一个实现简单的警报弹出窗口,其中包含动态消息和应用程序中按钮更改的数量。因为我的应用程序中有很多 AlertView。所以我需要动态更新。
下面我附上了自定义警报的示例图像,它看起来如何实现
请帮我实现这个功能。
标签 ios swift uialertview
<分区>
我必须使用 Swift 语言以编程方式在我的应用程序中实现自定义警报。我尝试使用一些第三方库“SCLAlertView”来实现,但无法从中理解,我需要一个实现简单的警报弹出窗口,其中包含动态消息和应用程序中按钮更改的数量。因为我的应用程序中有很多 AlertView。所以我需要动态更新。
下面我附上了自定义警报的示例图像,它看起来如何实现
请帮我实现这个功能。
最佳答案
使用pod SCLAlertView
安装pod后
您可以使用这些枚举选择Alert view Style
和Alert View Animation
样式
enum SCLAlertViewStyle: Int {
case Success, Error, Notice, Warning, Info, Edit, Wait
}
public enum SCLAnimationStyle {
case NoAnimation, TopToBottom, BottomToTop, LeftToRight, RightToLeft
}
SCLAlertView 有许多控件组,如添加文本字段、按钮和图标
这里是添加按钮的功能代码
let alertView = SCLAlertView()
alertView.addButton("First Button", target:self, selector:Selector("firstButton"))
alertView.addButton("Second Button") {
println("Second button tapped")
}
alertView.showSuccess("Button View", subTitle: "This alert view has buttons")
和警报 View 自定义类型
SCLAlertView().showError("Hello Error", subTitle: "This is a more descriptive error text.") // Error
SCLAlertView().showNotice("Hello Notice", subTitle: "This is a more descriptive notice text.") // Notice
SCLAlertView().showWarning("Hello Warning", subTitle: "This is a more descriptive warning text.") // Warning
SCLAlertView().showInfo("Hello Info", subTitle: "This is a more descriptive info text.") // Info
SCLAlertView().showEdit("Hello Edit", subTitle: "This is a more descriptive info text.") // Edit
在 Github Page 中你会发现很多设计精美的告警 View ,使用起来很方便
关于ios - 在 Swift 中如何创建自定义警报 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39127470/
相关文章:
ios - 防止在 UIImagePickerController 中选择同一张照片两次
ios - SwiftUI 中具有可变数量选项卡的自定义选项卡栏
iphone - 在 UIAlertView 响应中设置 NSString 的值,不能在其他地方使用吗?
ios - 在显示和关闭 `UIAlertView` 或 `UIAlertController` 时确定应用程序状态
ios - 全局访问 UIalertview 中的文本字段数据
ios - TableViewCell 中的 UISegmentedControl 不起作用。如何创建导出? tableview中是否可以有段控件