ChainableAlert-OC 1.0

ChainableAlert-OC 1.0

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布最后发布2016年8月

DingHub 维护。



  • DingHub

Alert 的链式调用。

我们有一个名为 ZRDChainableAlert 的辅助工具,和一个针对 UIViewController 的类别,用于添加 UI>alertController 的链式调用。

用法

在视图控制器中


#import "UIViewController+ZRDChainableAlert.h"
    [self actionSheet:@"Title" message:@"message"]
    .normalButton(@"normal1")
    .handler(^(ZRDChainableAlert *alert) {
        NSLog(@"normal1");
    })
    .normalButton(@"normal2")
    .normalButton(@"normal3")
    .destructiveButton(@"destructive1")
    .handler (^(ZRDChainableAlert *alert) {
        NSLog(@"destructive1");
    })
    .destructiveButton(@"destructive2")
    .cancelButton(@"cancel")
    .show
    .animated(YES)
    .completion(nil);

或一个包含文本字段的 alert

    [self alert:@"Title" message:@"message"]
    .configTextField(^(UITextField *textField) {
        textField.placeholder = @"UserName";
    })
    .configTextField(^(UITextField *textField) {
        textField.placeholder = @"Password";
        textField.secureTextEntry = YES;
    })
    .normalButton(@"Login")
    .handler(^(ZRDChainableAlert *alert) {
        NSArray *textFields = alert.textFields;
        NSLog(@"\nUsername:%@\nPassword:%@", [textFields[0] text], [textFields[1] text]);
    })
    .cancelButton(@"cancel")
    .show
    .animated(YES)
    .completion(nil);

支持 Pod

target 'YourTarget' do
pod 'ChainableAlert-OC'
end

您可以在以下处找到 Swift 版本:ChainableAlert