FSExtendedAlertKit 0.1.1

FSExtendedAlertKit 0.1.1

测试已测试
Lang语言 Obj-CObjective C
许可 BSD
发布上次发布2016年8月

Ell Neal维护。



  • 作者
  • Elliot Neal

注意:FSExtendedAlertKit 已过时。使用 UIAlertController,这是很好的。


FSExtendedAlertKit 提供简单的用于显示进度的 UIAlertView 替代品。共有五个主要类

FSBlockButton

FSBlockButton 是一个简单的 NSObject 子类,提供了一个带有标题和回调块的按钮包装器

FSBlockButton *blockButton = [FSBlockButton blockButtonWithTitle:@"A button" block:^ {
    // do something when the button is pressed
}];

FSAlertView

FSAlertView 是一个包装器,提供基于块回调而不是标准代理实现的回调

FSBlockButton *cancelButton = [FSBlockButton blockButtonWithTitle:@"Cancel" block:^ {
    // do something when the cancel button is pressed
}];

FSBlockButton *confirmButton = [FSBlockButton blockButtonWithTitle:@"Confirm" block:^ {
    // do something when the confirm button is pressed
}];

FSAlertView *alert = [[FSAlertView alloc] initWithTitle:@"Alert" message:@"Something needs your confirmation." cancelButton:cancelButton otherButtons:confirmButton, nil];

[alert show];

FSActivityIndicatorAlertView

FSActivityIndicatorAlertView 通过在 UIAlertView 内部显示 UIActivityIndicatorView 来显示不确定的进度

FSActivityIndicatorAlertView *alert = [[FSActivityIndicatorAlertView alloc] initWithTitle:@"Alert" message:@"Something is happening and might take a while."];

[alert show];

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^ {

    // do something that takes a while

    dispatch_async(dispatch_get_main_queue(), ^ {

        [alert dismiss:YES];
    });
});

FSProgressAlertView

FSProgressAlertView 通过在 UIAlertView 内部显示 UIProgressView 来显示确定性的进度

FSProgressAlertView *alert = [[FSProgressAlertView alloc] initWithTitle:@"Alert" message:@"Something is happening and might take a while."];

[alert show];

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^ {

    // do something that takes a while

    [alert setProgress:0.1f animated:YES];
    ...
    [alert setProgress:0.5f animated:YES];
    ...
    [alert setProgress:0.8f animated:YES];
    ...
    [alert setProgress:1.f animated:YES];

    dispatch_async(dispatch_get_main_queue(), ^ {

        [alert dismiss:YES];
    });
});

FSActionSheet

FSActionSheet 是一个包装器,提供基于块的回调而不是标准代理实现

FSBlockButton *cancelButton = [FSBlockButton blockButtonWithTitle:@"Cancel" block:^ {
    // do something when the cancel button is pressed
}];

FSBlockButton *deleteButton = [FSBlockButton blockButtonWithTitle:@"Delete" block:^ {
    // do something when the delete button is pressed
}];

FSBlockButton *editButton = [FSBlockButton blockButtonWithTitle:@"Edit" block:^ {
    // do something when the edit button is pressed
}];

FSActionSheet *actionSheet = [[FSActionSheet alloc] initWithTitle:nil cancelButton:cancelButton destructiveButton:deleteButton otherButtons:editButton, nil];

[actionSheet showInView:self.view];