YBAlertController 0.1.2

YBAlertController 0.1.2

测试已测试
Lang语言 SwiftSwift
许可协议 MIT
Released上次发布2016年1月
SPM支持 SPM

Yabuzaki 维护。



  • 作者
  • Yabuzaki

YBAlertController 是一个 Swift 库,提供整洁的操作表和警报

演示

Demo Demo

易于使用

let alertController = YBAlertController(title: "Menu", message: "Message", style: .ActionSheet)
// let alertController = YBAlertController(style: .ActionSheet)

// add a button
alertController.addButton(UIImage(named: "comment"), title: "Comment", target: self, selector: Selector("tap"))
// add a button with closure
alertController.addButton(UIImage(named: "tweet"), title: "Tweet", action: {
    print("button tapped")
})
// add a button (No image)
alertController.addButton("Open in Safari", target: self, selector: Selector("tap"))

// if you use a cancel Button, set cancelButtonTitle
// alertController.cancelButtonTitle = "Cancel"   

// show alert
alertController.show()

func tap() {
    print("tap")
}

自定义

按钮图标颜色

alertController.buttonIconColor = UIColor.blackColor()

覆盖颜色

alertController.overlayColor = UIColor(red:235/255, green:245/255, blue:255/255, alpha:0.7)

标题

// if title is nil or empty, the title Label is hidden
alertController.title = "Title"
alertController.titleFont = UIFont(name: "Avenir Next", size: 15)
alertController.titleTextColor = UIColor.blueColor()

消息

// if message is nil or empty, the message Label is hidden
alertController.message = "Message"
alertController.messageFont = UIFont(name: "Avenir Next", size: 15)
alertController.messageTextColor = UIColor.blueColor()

取消按钮

// if cancelButtonTitle is nil or empty, the cancel button is hidden
alertController.cancelButtonTitle = "Cancel"
alertController.cancelButtonFont = UIFont(name: "Avenir Next", size: 15)
alertController.cancelButtonTextColor = UIColor.blueColor()

按钮

alertController.buttonFont = UIFont(name: "Avenir Next", size: 15)
alertController.buttonTextColor = UIColor.blueColor()

触摸警报外部以关闭

alertController.touchingOutsideDismiss = true
// default, Alert:false ActionSheet:true

不使用动画

alertController.animated = false

安装

手动

只需将 YBAlertController.swift 拖到您的项目中。

使用方法

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

要求

  • iOS 7.0+

作者

Yabuzaki http://twitter.com/planet12app http://appstore.com/yutayabuzaki

许可协议

YBAlertController 在 MIT 许可协议下可用。有关更多信息,请参阅 LICENSE 文件。