DTAlertView 1.4.2

DTAlertView 1.4.2

测试已测试
语言语言 Obj-CObjective C
许可证 Apache 2
发布最新发布2015 年 3 月

Darktt 维护。



  • 作者:
  • Darktt

重要:iOS 8 上 UIWindow 的外观已更改,我无法在横屏视图上修复它。

所以我将为 iOS8 创建一个新的。

Perview 1Perview 2

自定义警报视图,解决 iOS7 上 UIAlertView 无法 addSubview 的问题。

新特性

显示和消失动画的新效果。

  • DTAlertViewAnimationSlideTop

Slide to top

  • DTAlertViewAnimationSlideBottom

Slide to bottom

  • DTAlertViewAnimationSlideLeft

Slide to left

  • DTAlertViewAnimationSlideRight

Slide to right

并且也可以在点击不同按钮时使用不同的消失动画。

Use different animation

新方法 -showForPasswordInputWithAnimation: 用于密码输入场景,以及动画 -shakeAlertView 用于密码错误场景。

Password error

注意

  • 此示例代码是在 Xcode 5.0 上创建的,但在 Xcode 4 或更早版本 上可能存在问题。
  • 示例代码在 非 ARC 模式下使用,但 DTAlertView 主类支持 ARC非 ARC 模式。

Q & A

问:如何在 iOS 7 上隐藏状态栏当警报显示时?

答:在您的 info.plist 中将 UIViewControllerBasedStatusBarAppearance 设置为 NO,状态栏将不会再出现。

安装

  1. 添加 QuartzCore 框架。
  2. DTAlertView 文件夹拖动到您的项目中。

用法

导入头文件并在想要使用的类中进行声明。

#import "DTAlertView.h"

在您的类中初始化 DTAlertView

// initial for class method
DTAlertView *alertView = [DTAlertView alertViewWithTitle:@"Demo" message:@"This is normal alert view." delegate:nil cancelButtonTitle:@"Cancel" positiveButtonTitle:@"OK"];

// inital for instance method
DTAlertView *alertView = [[DTAlertView alloc] initWithTitle:@"Demo" message:@"This is normal alert view." delegate:nil cancelButtonTitle:@"Cancel" positiveButtonTitle:@"OK"];

您可以使用 Block 与警报视图一起使用

DTAlertViewButtonClickedBlock block = ^(DTAlertView *_alertView, NSUInteger buttonIndex, NSUInteger cancelButtonIndex){
    // You can get button title of clicked button.
    NSLog(@"%@", _alertView.clickedButtonTitle);
};

DTAlertView *alertView = [DTAlertView alertViewUseBlock:block title:@"Demo" message:@"This is normal alert view with block." cancelButtonTitle:@"Cancel" positiveButtonTitle:nil];

显示 & 消失

显示警报视图

[alertView show];

消失警报视图

[alertView dismiss];

安装代码片段

Code Snippet 文件夹下的 codesnippet 文件复制到 ~/Library/Developer/Xcode/UserData/CodeSnippets/

  • 如果您的 Xcode 已开启,请退出 Xcode 然后重新打开 Xcode

您可以在那里找到代码片段。

Code Snippet

或者使用关键词 DTAlertViewButtonClickedBlockDTAlertViewTextDidChangeBlock

Key Word

安装文档集

使用 Xcode 文档查看器

Docset 文件夹下的 com.darktt.DTAlertView.docset 文件复制到 ~/Library/Developer/Shared/Documentation/DocSets/

  • 如果您的 Xcode 已开启,请退出 Xcode 然后重新打开 Xcode

您可以在文档查看器中找到它。

使用Dash

在Dash首选项中的Docset文件夹下添加com.darktt.DTAlertView.docset文件。

Dash preferences

许可证

根据Apache License,版本2.0(以下简称“许可证”);
除非遵守许可证,否则不得使用此文件。
您可以在以下位置获得许可证副本:

https://apache.ac.cn/licenses/LICENSE-2.0

除非适用的法律要求或书面同意,
在许可证下分发的软件按“现状”基础分发,不提供任何类型的保证或条件,
无论是明示的还是隐示的。
有关许可证下权限和限制的具体语言,请参阅许可证。
和限制的具体语言,请参阅许可证。
CocoaPods是一个由以下项目的贡献者共同创建的: