TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Apr 2016 |
In me the tiger sniffs the rose.
心有猛虎,细嗅蔷薇。
Welcome to My Blog: http://LeoDev.me
Now you could using UIAlertView with Block!
Fascinating? Yeah! So, just star this project now!
LCAlertView is available on CocoaPods. Just add the following to your project Podfile:
pod "LCAlertView-ObjC" # Podfile
Use by including the following import:
#import "LCAlertView.h"
Demo code:
// 1. Class method
LCAlertView *alertView = [LCAlertView title:@"LCAlertView" message:@"Quick Method" cancelButtonTitle:@"Cancel" otherButtonTitles:@[@"1", @"2"] clickedButtonAtIndex:^(LCAlertView *alertView, NSInteger buttonIndex) {
NSLog(@"clickedButtonAtIndex: %d", (int)buttonIndex);
}];
// 2. Instance method
LCAlertView *alertView = [[LCAlertView alloc] initWithTitle:@"LCAlertView" message:@"Quick Method" cancelButtonTitle:@"Cancel" otherButtonTitles:@[@"1", @"2", @"3"] clickedButtonAtIndex:^(LCAlertView *alertView, NSInteger buttonIndex) {
NSLog(@"clickedButtonAtIndex: %d", (int)buttonIndex);
}];
// show alertView
[alertView show];
You could also using properties:
LCAlertView *alertView = [[LCAlertView alloc] initWithTitle:@"LCAlertView" message:@"Block Properties" delegate:nil cancelButtonTitle:@"Cancel" otherButtonTitles:@"1", @"2", @"3", nil];
alertView.clickedButtonAtIndexBlock = ^(LCAlertView *alertView, NSInteger buttonIndex) {
NSLog(@"clickedButtonAtIndex: %d", (int)buttonIndex);
};
alertView.cancelBlock = ^(LCAlertView *alertView) {
NSLog(@"cancel");
};
// You should set `willPresentAlertViewBlock` before `- (void)show;`
// 设置 willPresentAlertViewBlock 一定要放在 `- (void)show;`方法之前
alertView.willPresentAlertViewBlock = ^(LCAlertView *alertView) {
NSLog(@"willPresentAlertView");
};
alertView.didPresentAlertViewBlock = ^(LCAlertView *alertView) {
NSLog(@"didPresentAlertView");
};
alertView.willDismissWithButtonIndexBlock = ^(LCAlertView *alertView, NSInteger buttonIndex) {
NSLog(@"willDismissWithButtonIndexBlock: %d", (int)buttonIndex);
};
alertView.didDismissWithButtonIndexBlock = ^(LCAlertView *alertView, NSInteger buttonIndex) {
NSLog(@"didDismissWithButtonIndex: %d", (int)buttonIndex);
};
[alertView show];
If you have any question, just commit a issue! Thx!
Mail: [email protected]
Blog: http://LeoDev.me