CJMAlertViewController 0.1.0

CJMAlertViewController 0.1.0

chenjm 维护。



  • 作者:
  • chenjm

CJMAlertViewController

CI Status Version License Platform

由于UIAlertViewController的局限性,使得添加一些视图都比较古怪,为了解决这个问题,从而实现了CJMAlertViewController。

  • 目前仅支持 Alert 的方式,不支持 ActionSheet 的方式

  • 目前仅支持添加 UILabel,UITextField,UIScrollView, UIView

后续有时间再继续更新。

示例

要运行示例项目,请克隆仓库,然后首先从 Example 目录运行 pod install

  • 初始化
CJMAlertViewController *vc = [[CJMAlertViewController alloc] init];
// 设置标题
vc.alertTitle = @"新建文件夹";
  • 添加 UILabel
[vc addLabelWithConfigurationHandler:^(UILabel * _Nonnull label) {
    label.text = @"请输入文件夹名称:";
}];
  • 添加 UITextField
[vc addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
    textField.placeholder = @"名称";
    textField.delegate = self;
}];
  • 添加 UIScrollView
[vc addScrollViewWithHeight:50 configurationHandler:^(UIScrollView * _Nonnull scrollView) {
    scrollView.showsHorizontalScrollIndicator = NO;
    scrollView.backgroundColor = [UIColor redColor];
}];
  • 添加 UIView
[vc addViewWithHeight:50 configurationHandler:^(UIView * _Nonnull view) {
    view.backgroundColor = [UIColor redColor];
}];
  • 添加事件
CJMAlertAction *cancelAction = [CJMAlertAction actionWithTitle:@"取消" style:0 handler:^(UIAlertAction * _Nonnull action) {
    [self.navigationController dismissViewControllerAnimated:YES completion:nil];
}];

[vc addAction:cancelAction];

CJMAlertAction *sureAction = [CJMAlertAction actionWithTitle:@"确定" style:0 handler:^(UIAlertAction * _Nonnull action) {
    [self.navigationController dismissViewControllerAnimated:YES completion:nil];
}];
[vc addAction:sureAction];
  • 显示视图
[self.navigationController presentViewController:vc animated:YES completion:^{
    
}];

需求

安装

CJMAlertViewController 通过 CocoaPods 提供。要安装,只需将以下行添加到您的 Podfile 中

pod 'CJMAlertViewController'

作者

chenjm, [email protected]

许可

CJMAlertViewController 在 MIT 许可下可用。有关更多信息,请参阅 LICENSE 文件。