Giter Site home page Giter Site logo

jqalertview's Introduction

#JQAlertView

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

导入

  1. 手动导入
  • JQAlertView.h JQAlertView.m
  1. 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...
   }];
   

jqalertview's People

Contributors

shlyren avatar

Stargazers

MohsinAli avatar 严兵胜 avatar  avatar

Watchers

James Cloos avatar MohsinAli avatar  avatar

Forkers

mohsinalimat

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.