AOAlertController 看起来与普通的 UIAlertController 类似,但每个操作项、标题、字体和颜色都可以自定义。
pod 'AOAlertController'AOAlertSettings 类配置为所有弹窗控制器的默认样式titleFontmessageFontdefaultActionFontcancelActionFontdestructiveActionFontbackgroundColorlinesColortitleColormessageColordefaultActionColordestructiveActionColorcancelActionColortapBackgroundToDismiss例如:AOAlertSettings.sharedSettings.backgroundColor = UIColor.redColor() — 这意味着对于所有的 AOAlertController 实例,都将默认设置红色背景。
对于单个控制器设置的属性优先级高于 AOAlertSettings 中的属性
控制器样式
AOAlertControllerStyle.AlertAOAlertControllerStyle.ActionSheet可用的控制器属性
actionItemHeightbackgroundColorlinesColortitleColortitleFontmessageColormessageFonttapBackgroundToDismiss示例
let alert = AOAlertController(title: "Title", message: nil, style: .Alert)
alert.titleFont = UIFont(name: "AvenirNext-Bold", size: 14)!动作样式
AOAlertActionStyle.DefaultAOAlertActionStyle.CancelAOAlertActionStyle.Destructive可用的属性
colorfont示例
let actionCancel = AOAlertAction(title: "Cancel", style: .Cancel, handler: nil)
actionCancel.color = UIColor.orangeColor()
alert.addAction(actionCancel)完整使用示例
let alert = AOAlertController(title: "Example Alert", message: "All in one", style: .Alert)
let action = AOAlertAction(title: "Default Action", style: .Default) {}
action.color = UIColor.blackColor()
let cancel = AOAlertAction(title: "Cancel", style: .Cancel, handler: nil)
alert.addAction(action)
alert.addAction(cancel)
self.navigationController?.presentViewController(alert, animated: false, completion: nil)