项目简介
强大的易于使用的提示框或者弹出框,应用于控制器或者窗口,支持模糊效果,自定义视图,自定义动画,使用自动布局,支持iphone和ipad。
CocoaPods
pod 'TYAlertController'
截屏
使用方法
1.将TYAlertController文件夹复制到你的项目,如果你想要模糊效果,开题报告,只要把Blur Effects Folder复制到你的项目中即可。
2.当你使用本项目时,开题报告,#import "UIView+TYAlertView.h",如果你想要模糊效果,那么#import "TYAlertController+BlurEffects.h"
3.你可以使用TYAlertController在控制器中展示,使用TYShowAlertView在窗口中展示,或者使用CategoryUIView+TYAlertView方便的显示提示框
使用方法demo
提示框周期阻塞
// 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 backgoundT
github地址:https://github.com/12207480/TYAlertController