Latest 1.2.6
Homepage https://github.com/shlyren/JQAlertView
License MIT
Platforms ios 8.0, requires ARC
Authors

一个类似于WeChat/Weibo的弹出视图, 支持从底部弹出以及从屏幕中心显示

JQAlertView

导入

  1. 手动导入
    • JQAlertView.h JQAlertView.m
  2. cocoapods
    • pod ‘JQAlertView’

使用

使用类似于UIAlertController

// 创建alertView
JQAlertView *alertView = [JQAlertView alertViewWithTitle:@"JQAlertViewDemo Title" message:@"This Is JQAlertViewDemo Message" preferredStyle:JQAlertControllerStyleActionSheet];

// 创建事件模型
JQAlertAction *action1 = [JQAlertAction actionWithTitle:@"default" style:JQAlertActionStyleDefault handler:^(JQAlertAction * _Nonnull action) {
    NSLog(@"default action");
}]; 
JQAlertAction *action2 = [JQAlertAction actionWithTitle:@"cancel" style:JQAlertActionStyleCancel handler:^(JQAlertAction * _Nonnull action) {
    NSLog(@"cancel action");
}]; 
JQAlertAction *action3 = [JQAlertAction actionWithTitle:@"destructive" style:JQAlertActionStyleDestructive handler:^(JQAlertAction * _Nonnull action) {
    NSLog(@"destructive action");
}];

// 添加事件模型
[alertView addActions:@[action1, action2, action3]];
// 显示
[alertView show];

快速创建:

[JQAlertView showAlertViewWithTitle:@"showAlert"
                                message:@"alertView style"
                         preferredStyle:JQAlertViewStyleActionSheet
                                 titles:@[@"JQAlertViewStyleActionSheet", @"JQAlertViewStyleAlert"]
                       destructiveTitle:nil
                            cancelTitle:@"cancel"
                                handler:^(JQAlertView * _Nonnull alertView, NSInteger index) {

        if (index > 1) return;

        [JQAlertView showAlertViewWithTitle:alertView.message
                                    message:[NSString stringWithFormat:@"%zd",index]
                             preferredStyle:index
                                     titles:@[@"action1", @"action2"]
                           destructiveTitle:@"delete"
                                cancelTitle:@"cancel"
                                    handler:^(JQAlertView * _Nonnull alertView, NSInteger index) {

              NSLog(@"index == %zd, title: %@", index, alertView.title);
         }];

    }];

直接弹出一个JQAlertViewStyleActionSheet样式

 [JQAlertView showActionSheetWithTitle:@"showAlert"
                               message:@"alertView style"
                                titles:@[@"JQAlertViewStyleActionSheet"]
                      destructiveTitle:nil
                           cancelTitle:@"cancel"
                               handler:^(JQAlertView * _Nonnull alertView, NSInteger index) {
        // action...
   }];

Latest podspec

{
    "name": "JQAlertView",
    "version": "1.2.6",
    "summary": "u4e00u4e2au7c7bu4f3cu4e8eu5faeu4fe1u7684u5f39u51fau89c6u56fe",
    "homepage": "https://github.com/shlyren/JQAlertView",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "shlyren": "[email protected]"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/shlyren/JQAlertView.git",
        "tag": "1.2.6"
    },
    "requires_arc": true,
    "source_files": "JQAlertView/*.{h,m}"
}

Pin It on Pinterest

Share This