Giter VIP home page Giter VIP logo

customalert's Introduction

CustomAlert


本功能在 参考了github上其他开源项目基础上,经过更改适配后,代码轻量,用法简单。包括tableAlert和普通Alert两种类型。

CustomTableViewAlert自定义tableAlert


img

功能说明

  • 会根据数据源的多少显示table的行数和行高
  • 设置单选
  • 设置多选
  • 底部按钮和顶部标题可配置

用法

NSArray* array = @[@"第一行", @"第二行", @"第三行",@"第四行", @"第五行", @"第六行",@"第七行", @"第八行", @"第九行",@"第十行", @"第十一行", @"第十二行"];
WTTableAlertView* alertview = [WTTableAlertView initWithTitle:@"单选" options:array singleSelection:YES selectedItems:@[@(3)] completionHandler:^(NSArray * _Nullable options) {
  for (id obj in options) {
       NSLog(@"默认单选:%@", obj);
    }
                    
}];
[alertview show];
  • 导入头文件,按照demo做相关设置。
  • 采用代码添加约束,可更改设置的值

CustomAlert

iOS原生的UIAlertController由于是全局的并且是一个控制器,因此在多人开发多个模块时时,容易造成意想不到的结果,这在开发SDK时,其弊端展示的尤为明显。由于这个这个原因,本示例以UIView的形式展示弹窗并将其添加到Window上。并附带了多个功能。

WTAlertView* alertView = [[WTAlertView alloc] init];
alertView.onButtonTouchUpInside = ^(WTAlertView * _Nonnull alertView, NSInteger buttonIndex) {
       NSLog(@"alertView点击了第%ld个按钮",(long)buttonIndex);
       [alertView close];
  };
[alertView setButtonTitles:[NSMutableArray arrayWithObjects:@"取消", @"确定", nil]];
[alertView show];

功能说明

  • 自定义Alert视图
  • 可设置标题和内容
  • 可设置按钮倒计时后自动移除Alert
  • 可设置触摸非Alert区域是否移除Alert
  • 在展示前,会先移除界面上之前的Alert

仅展示标题

img

仅展示内容

img

同时展示标题和内容

img

展示倒计时

img

自定义内容

img

customalert's People

Contributors

wutao23yzd avatar

Watchers

James Cloos avatar li avatar

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.