Harness the UIAlertController with a simplified, chainable and expressive syntax.
See Demo/YZAlertControllerDemo.xcodeproj
- Add
pod 'YZAlertController'to your Podfile. - Run
pod installorpod update. - Import <YZAlertController/YZAlertController.h>.
- Download all the files in the
YZAlertControllersubdirectory. - Add the source files to your Xcode project.
- Link with required frameworks:
- UIKit
- CoreFoundation
This library requires iOS 8.0+ and Xcode 9.0.
Heres the same UIAlertController created using YZAlertController
[[[[[[YZAlertController.title(@"title").message(@"message").preferredStyle(UIAlertControllerStyleAlert)
addAction:nil](@"Action1", UIAlertActionStyleDestructive)
addAction:nil](@"Action2", UIAlertActionStyleDefault)
addAction:^(UIAlertAction *action) {
NSLog(@"action title is:%@",action.title);
}](@"Action", UIAlertActionStyleCancel)
addTextFieldWithConfigurationHandler:^(UITextField *textField) {
textField.placeholder = @"textField";
}]addTextFieldWithConfigurationHandler:^(UITextField *textField) {
textField.placeholder = @"textField";
}]addTextFieldWithConfigurationHandler:^(UITextField *textField) {
textField.placeholder = @"textField";
}].showOnCtr(ctr);YZAlertController 是将UIAlertController使用简化的、可链接的和表达性的语法来封装利用。
查看并运行 Demo/YZAlertControllerDemo.xcodeproj
- 在 Podfile 中添加
pod 'YZAlertController'。 - 执行
pod install或pod update。 - 导入 <YZAlertController/YZAlertController.h>。
- 下载 YZAlertController 文件夹内的所有内容。
- 将 YZAlertController 内的源文件添加(拖放)到你的工程。
- 链接以下 frameworks:
- UIKit
- CoreFoundation
该项目最低支持 iOS 8.0 和 Xcode 9.0。
使用YZAlertController创建一个相同的UIAlerController
[[[[[[YZAlertController.title(@"title").message(@"message").preferredStyle(UIAlertControllerStyleAlert)
addAction:nil](@"Action1", UIAlertActionStyleDestructive)
addAction:nil](@"Action2", UIAlertActionStyleDefault)
addAction:^(UIAlertAction *action) {
NSLog(@"action title is:%@",action.title);
}](@"Action", UIAlertActionStyleCancel)
addTextFieldWithConfigurationHandler:^(UITextField *textField) {
textField.placeholder = @"textField";
}]addTextFieldWithConfigurationHandler:^(UITextField *textField) {
textField.placeholder = @"textField";
}]addTextFieldWithConfigurationHandler:^(UITextField *textField) {
textField.placeholder = @"textField";
}].showOnCtr(ctr);YZAlertController 使用 MIT 许可证,详情见 LICENSE 文件。