一个令人愉快的警报视图框架,兼容 iOS 7.0 及更高版本。它既提供 Objective-C 又提供 Swift 版本。
[[ZRAlertController defaultAlert] alertShowWithTitle:@"提示" message:@"这是一条空消息!" okayButton:@"Ok"];
[[ZRAlertController defaultAlert] alertShowWithTitle:@"Note" message:@"This is an empty message!" cancelButton:@"Cancel" okayButton:@"Ok" okayHandler:^{
NSLog(@"You clicked the okay button.");
} cancelHandler:^{
NSLog(@"You clicked the cancel button.");
}];
[[ZRAlertController defaultAlert] alertShowWithTitle:@"Note" message:@"This is an explanation message!" cancelButton:@"Cancel" okayButton:@"Okay" alertStyle:ZRAlertStyleSecureTextInput placeHolder:@"Type any character" okayHandler:^(UITextField *textFiled) {
NSLog(@"Your input of textFiled is %@.", textFiled.text);
} cancelHandler:^(UITextField *textFiled) {
NSLog(@"Your input of textFiled is %@.", textFiled.text);
}];
[[ZRAlertController defaultAlert] alertShowWithTitle:@"Note"
message:@"This is an explanation message!"
cancelButton:@"Cancel" okayButton:@"Ok"
alertStyle:ZRAlertStyleLoginAndPasswordInput
placeHolder1:@"Type an account"
placeHolder2:@"Type a passcode"
sureHandler:^(UITextField *textFiled1, UITextField *textFiled2) {
NSLog(@"Your input of Sure textFiled1.text = %@, textFiled2.text = %@. ", textFiled1.text, textFiled2.text);
} abolishHandler:^(UITextField *textFiled1, UITextField *textFiled2) {
NSLog(@"Your input of Abolish textFiled1.text = %@, textFiled2.text = %@. ", textFiled1.text, textFiled2.text);
}];
[[ZRAlertController defaultAlert] actionViewWithTitle:nil cancel:@"cancel" others:@[@"aaa",@"bbb",@"ccc"] handler:^(int index, NSString * _Nonnull item) {
NSLog(@"index = %d, item = %@. ", index, item);
}];