ARNAlert 0.2.2

ARNAlert 0.2.2

测试已测试
Lang语言 Obj-CObjective C
许可证 MIT
发布最新发布2015年9月

airin维护。



ARNAlert 0.2.2

  • 作者:
  • Airin

UIAlertView和UIAlertController的包装。

使用方法

要运行示例项目,请克隆仓库,并首先从Example目录运行pod install

显示无操作警报

[ARNAlert showNoActionAlertWithTitle:@"no action title" message:@"no action message" buttonTitle:@"No Acttion"];

// iOS8 : UIAlertController addAction(UIAlertActionStyleCancel)
// iOS7 : UIAlertView clickedButtonAtIndex(cancelButtonIndex)

显示简单操作警报

[ARNAlert showAlertWithTitle:@"test Title"
                     message:@"test Message"
           cancelButtonTitle:@"Cancel"
                 cancelBlock:^(id action){
                     NSLog(@"cancelBlock call!");

                     // iOS8 : UIAlertController addAction(UIAlertActionStyleCancel)
                     // iOS7 : UIAlertView clickedButtonAtIndex(cancelButtonIndex)
                 }
               okButtonTitle:@"OK"
                     okBlock:^(id action){
                     NSLog(@"okBlock call!");

                     // iOS8 : UIAlertController addAction(UIAlertActionStyleDefault)
                     // iOS7 : UIAlertView clickedButtonAtIndex(buttonIndex)
}];

显示某些操作警报

ARNAlert *alert = [[ARNAlert alloc] initWithTitle:@"test Title" message:@"test Message"];
[alert addActionTitle:@"button" actionBlock:^(id action) {
    NSLog(@"button Button tapped!");

    // iOS8 : UIAlertController addAction(UIAlertActionStyleDefault)
    // iOS7 : UIAlertView clickedButtonAtIndex(buttonIndex)
}];
[alert setCancelTitle:@"cancel" cancelBlock:^(id action) {
    NSLog(@"cancel Button tapped!");

    // iOS8 : UIAlertController addAction(UIAlertActionStyleCancel)
    // iOS7 : UIAlertView  clickedButtonAtIndex(cancelButtonIndex)
}];
[alert show];

显示某些文本字段警报

    ARNAlert *alert = [[ARNAlert alloc] initWithTitle:@"test Text " message:@"test Message"];

    [alert addTextFieldWithPlaceholder:@"place1" fillInText:@"tex1"];
    [alert addTextFieldWithPlaceholder:@"place2" fillInText:@"tex2"];
    // iOS7 is Nothing
    [alert addTextFieldWithPlaceholder:@"place3" fillInText:@"tex3"];

    [alert addActionTitle:@"button1"
              actionBlock:^(NSArray *texitFields) {
                  NSLog(@"button1 tapped!");
                  NSLog(@"texitFields : %@", texitFields);
                  for (int i = 0; i < texitFields.count; ++i) {
                      UITextField *textField = texitFields[i];
                      NSLog(@"texitField.text : %@", textField.text);
                  }
              }];
    [alert addActionTitle:@"button2"
              actionBlock:^(NSArray *texitFields) {
                  NSLog(@"button2 tapped!");
                  NSLog(@"texitFields : %@", texitFields);
                  for (int i = 0; i < texitFields.count; ++i) {
                      UITextField *textField = texitFields[i];
                      NSLog(@"texitField.text : %@", textField.text);
                  }
              }];
    [alert setCancelTitle:@"Cancel"
              cancelBlock:^(NSArray *texitFields) {
                  NSLog(@"cancel Button tapped!");
                  NSLog(@"texitFields : %@", texitFields);
                  for (int i = 0; i < texitFields.count; ++i) {
                      UITextField *textField = texitFields[i];
                      NSLog(@"texitField.text : %@", textField.text);
                  }
              }];

    [alert show];

需求

  • iOS 7.0+
  • ARC

安装

许可证

ARNAlert在MIT许可证下可用。有关更多信息,请参阅LICENSE文件。