UNAlertView 0.2.0

UNAlertView 0.2.0

测试已测试
Lang语言 SwiftSwift
许可证 MIT
发布最后发布2018年11月
SPM支持SPM

ytakzk维护。



  • ytakzk

UNAlertView

UNAlertView是一个简单外观的灵活UIAlertView替代品。
它允许您对消息进行对齐,并更改按钮的方向。

Version Platform CI Status Carthage compatible

预览

功能

  • 使用窗口进行显示
  • 闭包语法
  • 支持UIAppearance
  • 轻松更改按钮方向(只需1行代码。)
  • 对齐消息(UIAlertView和UIAlertViewController不支持。)
  • 通用用途(支持iOS7、iOS8和iOS9,无需任何条件分支。)

安装

将类文件夹拖放到您的Xcode项目中。
您也可以使用cocoapods或Cartfile。

使用cocoapods

pod 'UNAlertView'添加到您的Podfile中并运行pod install。同时将use_frameworks!添加到Podfile中。

use_frameworks!
pod 'UNAlertView'

使用Carthage

github "ytakzk/UNAlertView" 添加到您的 Cartfile中并运行 carthage update`。如果您对Carthage不熟悉,请查看他们的入门部分

github "ytakzk/UNAlertView"

UNAlertView 使用指南

导入 UNAlertView import UNAlertView,然后在需要显示视图时使用以下代码。

let alertView = UNAlertView(title: "TITLE", message: "MESSAGE")

alertView.addButton("Yes", action: {

print("Yes action")
})

alertView.addButton("No", action: {

print("No action")
})

// Show
alertView.show()

添加带颜色的按钮

alertView.addButton("Title",
backgroundColor: UIColor(white: 0.1, alpha: 1.0),
fontColor: UIColor.whiteColor(),
action: {

print("Some Action")
})

// The default font color is white.
alertView.addButton("Title",
backgroundColor: UIColor(white: 0.1, alpha: 1.0),
action: {

print("Some Action")
})

对齐

// Message
alertView.messageAlignment = NSTextAlignment.Left // NSTextAlignment is used here.

// Buttons
alertView.buttonAlignment  = UNButtonAlignment.Horizontal // UNButtonAlignment.Vertical

更改字体

// Title
alertView.titleFont   = UIFont(name: "Avenir-Next-Bold", size: 16)

// Message
alertView.messageFont = UIFont(name: "Avenir-Next", size: 16)

作者

ytakzk
http://ytakzk.me

许可

UNAlertView遵循MIT许可协议发布。
请参阅LICENSE获取详细信息。