URBNAlert 3.1.1

URBNAlert 3.1.1

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布上次发布2020年2月

Ryan GarchinskyJason GrandelliNicole SouvenirMatt ThomasURBNEvan DutcherRaymond Migneco维护。



URBNAlert 3.1.1

  • Kevin Taniguchi

URBNAlert

CI Status Version License Platform

示例

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

使用方法

将 URBNAlert 添加到项目的 Podfile 后,使用以下导入行导入 URBNAlert: #import URBNAlert

设置警报样式

var alertStyler = AlertStyler()

// Blur Styling
alertStyler.blur.isEnabled = false
alertStyler.blur.tint = UIColor.red

// Button Styling
alertStyler.button.backgroundColor = UIColor.white
alertStyler.button.highlightBackgroundColor = .UIColor.lightGray
alertStyler.button.titleColor = UIColor.black

// Message Styling
alertStyler.message.color = UIColor.darkGray
alertStyler.message.backgroundColor = UIColor.white

// Assign styler to your alert
let alert = AlertViewController(message: “Alert Title”)
alert.alertStyler = alertStyler

1 操作警报示例

Alt text

let alert = AlertViewController(message: “Alert Title”)

let action = AlertAction(type: .custom, title: “Action Title”), completion: { _ in
    // Perform action here
}

alert.addActions([action])

alert.show()

2 操作警报示例

Alt text

3+ 操作警报示例

Alt text

自定义视图警报示例

Alt text

let imageView = UIImageView(image: UIImage.stretchableImage(color: .blue))
imageView.contentMode = .scaleAspectFit
imageView.heightAnchor.constraint(equalToConstant: 200).isActive = true

let stackView = UIStackView(arrangedSubviews: [customLabel, imageView])
stackView.axis = .vertical
stackView.spacing = 10
let containerView = UIView()

containerView.widthAnchor.constraint(equalToConstant: view.frame.width - 2 * 30).isActive = true
containerView.embed(subview: stackView, insets: UIEdgeInsets(top: 0, left: 18, bottom: 18, right: 18))

文本字段警报示例

Alt text

let alert = AlertViewController(title: "Alert Title", message: sampleMessage)

alert.addTextfield { textField in
    textField.setStylesForAlert()
}

alert.addActions(action)
alert.show()

要求

安装

URBNSwiftAlert 通过 CocoaPods 提供使用。要安装它,只需将以下行添加到您的 Podfile 文件中

pod "URBNSwiftAlert"

作者

URBN 移动团队,[email protected]

许可

URBNSwiftAlert 在 MIT 许可下可用。更多信息请参阅 LICENSE 文件。