前言:意义在于创建一个与 UIAlertView 控件类似,并且更具版本兼容性的例子
Gif 示例
优点
- 在iOS 7.0之后可用
- 头部图片(可选)
- 标题,描述(可选)
- 松耦合(显示新控制器)
- 使用 UIKit Dynamics 的动画
特性
- 提供更多有趣且强大的功能的扩展
CocoaPods
- 将
pod 'XTAlertViewController', '~> 1.0.1'
添加到您的 Podfile 中 - 运行
pod install
或 pod update --no-repo-update 导入 <XTAlertView.h>
使用方法
// init obj
// Give a picture name
// Give a picture's height
// Give a btn's title array
// Give a title
// Give a describtion
// Give a style two btn | double btn
// example 1
[[XTAlertViewController new] showViewWithImage:@"summerxx" imageHeight:188 title:@"This is an introduction" btnTitles:@[@"Cancel", @"Determine"] des:@"A simple and easy to use more version using the controls Copyright © 2016年 夏天然后. All rights reserved." style:AlertDefault fromVC:self];
// example 2
XTAlertViewController *xtAlert = [[XTAlertViewController alloc] init];
[xtAlert showViewWithImage:@"summerxx" imageHeight:188 title:@"This is an introduction" btnTitles:@[@"Cancel", @"Determine", @"Okey"] des:@"A simple and easy to use more version using the controls Copyright © 2016年 夏天然后. All rights reserved." style:AlertDouble fromVC:self];
xtAlert.delegate = self;
如果你使用代理方法
// Signed an delegate
@interface ViewController ()<XTAlertControllerDelegate>
//
xt.delegate = self;
按照这种方式实现代理方法
- (void)xt_alertViewControllerClickIndex:(NSInteger)buttonIndex
{
switch (buttonIndex) {
case 0:
NSLog(@"0");
NSLog(@"Cancel");
break;
case 1:
NSLog(@"1");
NSLog(@"Determine");
break;
case 2:
NSLog(@"2");
NSLog(@"summerxx");
break;
default:
break;
}
}
贡献
- 如需帮助,请创建一个问题。
- 如果你发现了错误,请创建一个问题。
- 如果你有新的需求,也要创建一个问题。
致谢
由 summerxx27 制作,感谢您的使用
MIT 许可证
XTAlertController 在 MIT 许可证下可用。更多信息请参阅 LICENSE 文件。