Skip to content

Latest commit

 

History

History
148 lines (116 loc) · 9.86 KB

README_CN.md

File metadata and controls

148 lines (116 loc) · 9.86 KB

JCAlertController继承于UIViewController,可以作为替代UIAlertController的弹窗库,使用简单,可自定义程度高。

比较 队列管理 自定义样式 自定义view 最低支持系统
JCAlertController 支持 简单 简单 iOS 7
UIAlertController 不支持 复杂 复杂 iOS 8
  • 支持队列管理
  • 支持自定义样式
  • 支持自定义contentView

什么是队列管理 ?

请看下面的伪代码:

[self presentWithFIFO:alert1];
[self presentWithFIFO:alert2];
[self presentWithFIFO:alert3];

结果:
alert1第一个显示, 被用户关闭后, alert2第二个显示, 被用户关闭后, alert3第三个显示
就像这样: alert1 >> alert2 >> alert3

[self presentWithLIFO:alert1];
[self presentWithLIFO:alert2];
[self presentWithLIFO:alert3];

结果:
alert3第一个显示, 被用户关闭后, alert2第二个显示, 被用户关闭后, alert1第三个显示
就像这样 alert3 >> alert2 >> alert1

Present顺序由 JCPresentQueue管理,支持cocoapods导入。你可以用它来自动管理任何UIAlertController库的弹出顺序。 如果你已经导入了JCAlertController就不用再导入JCPresentQueue了。

预览

默认样式(标题和内容都有)

默认样式(只有标题)

默认样式(只有内容)

默认样式 (超长文字)

自定义样式

自定义View

自定义View+键盘处理

自定义View+富文本

文件结构

.
|____.DS_Store
|____AlertView
| |____JCAlertView.h
| |____JCAlertView.m
|____ButtonItem
| |____JCAlertButtonItem.h
| |____JCAlertButtonItem.m
|____Category
| |____NSAttributedString+JCCalculateSize.h
| |____NSAttributedString+JCCalculateSize.m
| |____UIColor+JCHightlightedColor.h
| |____UIColor+JCHightlightedColor.m
| |____UIImage+JCColor2Image.h
| |____UIImage+JCColor2Image.m
| |____UIViewController+JCPresentQueue.h // present category
| |____UIViewController+JCPresentQueue.m
| |____UIWindow+JCBlur.h
| |____UIWindow+JCBlur.m
|____JCAlertController.h // import this
|____JCAlertController.m
|____Style
| |____JCAlertStyle.h
| |____JCAlertStyle.m
| |____JCAlertStyleAlertView.h
| |____JCAlertStyleAlertView.m
| |____JCAlertStyleBackground.h
| |____JCAlertStyleBackground.m
| |____JCAlertStyleButton.h
| |____JCAlertStyleButton.m
| |____JCAlertStyleButtonCancel.h
| |____JCAlertStyleButtonCancel.m
| |____JCAlertStyleButtonNormal.h
| |____JCAlertStyleButtonNormal.m
| |____JCAlertStyleButtonWarning.h
| |____JCAlertStyleButtonWarning.m
| |____JCAlertStyleContent.h
| |____JCAlertStyleContent.m
| |____JCAlertStyleSeparator.h
| |____JCAlertStyleSeparator.m
| |____JCAlertStyleTitle.h
| |____JCAlertStyleTitle.m

使用CocoaPods集成

step 1

platform :ios, '7.0'
target 'your target' do
pod 'JCAlertController'
end

step 2

#import "JCAlertController.h"

如何使用

// LIFO: alert3 >> alert2 >> alert1
for (int i = 1; i<4; i++) {
JCAlertController *alert = [JCAlertController alertWithTitle:[NSString stringWithFormat:@"alert%zi", i] message:nil];
[alert addButtonWithTitle:@"OK" type:JCButtonTypeNormal clicked:nil];
[self jc_presentViewController:alert presentCompletion:nil dismissCompletion:nil];
}

Contact me

E-mail: hjaycee@163.com
Blog: http://www.jianshu.com/u/8bde69945e50