TYAlertController 1.2.0

TYAlertController 1.2.0

测试已测试
语言语言 Obj-CObjective C
许可协议 MIT
发布最后发布2017年11月

tany维护。



  • 作者:
  • tany

强大的、易于使用的 alertView 或 popupView,在控制器和窗口中使用,支持模糊效果、自定义视图和自定义动画,支持 AutoLayout,适用于 iPhone 和 iPad。

屏幕截图

image

要求

  • Xcode 5 或更高
  • iOS 7.0 或更高
  • ARC

使用

1. 将 TYAlertController 文件夹复制到您的项目中,如果需要模糊效果,需要将 Blur Effects 文件夹复制到您的项目中。
2. 当您使用它时,如果要使用模糊效果,请导入 "TYAlertController+BlurEffects.h",然后导入 "UIView+TYAlertView.h"
3. 您可以在控制器中使用 TYAlertController 显示,或在窗口中使用 TYShowAlertView 显示,或使用 Category UIView+TYAlertView 方便显示 alertview。
4. 查看示例,它包含更多有用用法和示例。

使用示例

  • alertView 生命周期块
// alertView lifecycle block
@property (copy, nonatomic) void (^viewWillShowHandler)(UIView *alertView);
@property (copy, nonatomic) void (^viewDidShowHandler)(UIView *alertView);
@property (copy, nonatomic) void (^viewWillHideHandler)(UIView *alertView);
@property (copy, nonatomic) void (^viewDidHideHandler)(UIView *alertView);

// dismiss controller completed block
@property (nonatomic, copy) void (^dismissComplete)(void);
  • 在控制器中显示(两种方式)(推荐)
TYAlertView *alertView = [TYAlertView alertViewWithTitle:@"TYAlertView" message:@"This is a message, the alert view containt text and textfiled. "];

    [alertView addAction:[TYAlertAction actionWithTitle:@"取消" style:TYAlertActionStyleCancle handler:^(TYAlertAction *action) {
        NSLog(@"%@",action.title);
    }]];

    [alertView addAction:[TYAlertAction actionWithTitle:@"确定" style:TYAlertActionStyleDestructive handler:^(TYAlertAction *action) {
        NSLog(@"%@",action.title);
    }]];

    [alertView addTextFieldWithConfigurationHandler:^(UITextField *textField) {
        textField.placeholder = @"请输入账号";
    }];
    [alertView addTextFieldWithConfigurationHandler:^(UITextField *textField) {
        textField.placeholder = @"请输入密码";
    }];

    // first way to show
    TYAlertController *alertController = [TYAlertController alertControllerWithAlertView:alertView preferredStyle:TYAlertControllerStyleAlert];
    //alertController.alertViewOriginY = 60;
    [self presentViewController:alertController animated:YES completion:nil];

    // second way to show,use UIView Category
    //[alertView showInController:self preferredStyle:TYAlertControllerStyleAlert];
  • 在窗口中显示(两种方式)
TYAlertView *alertView = [TYAlertView alertViewWithTitle:@"TYAlertView" message:@"A message should be a short, but it can support long message"];

    [alertView addAction:[TYAlertAction actionWithTitle:@"取消" style:TYAlertActionStyleCancle handler:^(TYAlertAction *action) {
        NSLog(@"%@",action.title);
    }]];

    [alertView addAction:[TYAlertAction actionWithTitle:@"确定" style:TYAlertActionStyleDestructive handler:^(TYAlertAction *action) {
        NSLog(@"%@",action.title);
    }]];

    // first way to show ,use UIView Category
    [alertView showInWindowWithOriginY:200 backgoundTapDismissEnable:YES];

    // second way to show
   // [TYShowAlertView showAlertViewWithView:alertView originY:200 backgoundTapDismissEnable:YES];

联系

如果您发现错误,请向我请求拉取请求
如果您有好的想法,请联系我,邮箱:[email protected]