ZFAlertController 1.0.9

ZFAlertController 1.0.9

Franlucky 维护。



  • Pokeey

ICU-Coders

MIT Build Status podversion Platform

中文说明

ZFAlertController 是一个高度可自定义的 iOS AlertController。选择 ZFAlertController 为您的下一个项目,或将现有项目迁移到它——您会为此而开心的!

ZFAlertController 添加到项目中

CocoaPods

CocoaPods 是将 ZFAlertController 添加到项目的推荐方式。在 Podfile 中指定它

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'

target 'TargetName' do
pod 'ZFAlertController', '~> 1.0.9'
end

然后,运行以下命令:

pod install --repo-update

源文件

或者,您可以直接将 ZFAlertController.hZFAlertController.m 源文件添加到您的项目中。

  1. 下载最新代码版本 最新代码版本 或将存储库作为 git 子模块添加到您的跟踪项目中。
  2. 在 Xcode 中打开您的项目,然后将 ZFAlertController.hZFAlertController.m 拖放到项目 (使用“产品导航器视图”)。如果您在项目外部提取代码存档,请确保选中复制项。
  3. 使用 #import "ZFAlertController.h"ZFAlertController 包含到您需要的地方。

使用方法

UIAlertController 相同

创建普通警报

alert

ZFAlertController *alertVC = [ZFAlertController alertWithTitle:@"ZFAlertController" message:@"alertWithTitle:message:style:" style:ZFAlertControllerStyleAlert];

ZFAlertAction *ok = [ZFAlertAction actionWithTitle:@"ok" action:^{
}];
ZFAlertAction *cancel = [ZFAlertAction actionWithTitle:@"cancel" action:^{
}];

[alertVC addAction:ok];
[alertVC addAction:cancel];

[self presentViewController:alertVC animated:YES completion:nil];

添加文本框,这将根据键盘自动调整

textFiled

ZFAlertController *alertVC = [ZFAlertController alertWithTitle:@"Alert" message:@"alertWithTitle:message:style:" style:ZFAlertControllerStyleAlert];

[alertVC addTextFiledWithText:@"" placeholder:@"Input..." textFieldTextChangedCallback:^(NSString * _Nonnull text, UITextField * _Nonnull textField) {
    NSLog(@"text1:%@", text);
}];
ZFAlertAction *ok = [ZFAlertAction actionWithTitle:@"Ok" action:^{
    NSLog(@"ok");
    [self testFunc];
}];

[alertVC addAction:ok];
[self presentViewController:alertVC animated:YES completion:nil];

操作表

actionSheet

ZFAlertController *alertVC = [ZFAlertController alertWithTitle:@"ActionSheet" message:@"alertWithTitle:message:style:" style:ZFAlertControllerStyleActionSheet];

ZFAlertAction *ok = [ZFAlertAction actionWithTitle:@"Ok" action:^{
}];
ZFAlertAction *cancel = [ZFAlertAction actionWithTitle:@"Cancel" action:^{
}];

[alertVC addAction:ok];
[alertVC addAction:cancel];

[self presentViewController:alertVC animated:YES completion:nil];

定制程度如何

custom

添加自定义视图,imageView,label等

[alertVC addCustomView:^UIView * _Nonnull{
    UIView *customView = [[UIView alloc] init];
    [customView setBackgroundColor:[UIColor greenColor]];
    return customView;
} config:^(UIView * _Nonnull contentView, UIView * _Nonnull customView) {
    [customView setFrame:CGRectMake(contentView.frame.origin.x + 40, contentView.frame.origin.y - 40, contentView.frame.size.width - 40 * 2, 30)];
}];

并且添加自定义按钮

[alertVC addCustomButton:^UIButton * _Nonnull{
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    [button setImage:[UIImage imageNamed:@"close"] forState:UIControlStateNormal];
    return button;
} buttonAction:^(UIViewController * _Nonnull alert) {
    [alert dismissViewControllerAnimated:YES completion:nil];
} config:^(UIView * _Nonnull contentView, UIView * _Nonnull customView) {
    // or masonry here
    [customView setFrame:CGRectMake(CGRectGetMaxX(contentView.frame) - 44, contentView.frame.origin.y - 44 - 10, 44, 44)];
}];

更多请查阅项目中的 sample

如果有错误,请告知。
如果您感觉舒适,也许您可以给它一个星🌟
感谢您的时间。

MIT 许可证

版权所有 (c) 2019 Pokeey

在此特此授予任何获取本软件及其关联文档文件(以下简称“软件”)副本的人免费权利,在不限制的情况下处理软件,包括但不限于使用、复制、修改、合并、发布、分发、许可和/或销售软件副本,并允许获得软件的人这样做,前提是遵守以下条件:

所有副本或软件的大部分内容均应包含上述版权声明和本许可声明。

软件按“原样”提供,不提供任何形式的保证,无论是明示的还是隐含的,包括但不限于对适销性、特定用途的适用性和非侵权的保证。在任何情况下,作者或版权所有者均不对任何索赔、损害或其他责任承担责任,无论是基于合同、侵权或其他方式,是由软件引起的、与软件有关的、出于或与软件的使用或其他处理有关的。