AFDropdownNotification

Dropdown notification view for iOS.

下拉通知的view,用于iOS.

Installation - 安装

If you're using CocoaPods, just add this line to your Podfile:

如果你正在使用CocoaPods,只要加这么一句话到Podfile中即可:

pod 'AFDropdownNotification', '~> 1.0'

If you're not, import these files to your project:

你可以直接将文件拖到你的项目当中:

AFDropdownNotification.h
AFDropdownNotification.m

Usage - 使用

First of all, init your AFDropdownNotification class and set your main class asAFDropdownNotificationDelegate:

首先,进入AFDropdownNotification这个类,设置你的asAFDropdownNotificationDelegate的代理方法:

AFDropdownNotification *notification = [[AFDropdownNotification alloc] init];
notification.notificationDelegate = self;

You can configure the title text with the titleText property, the subtitle text with subtitleText, an optional left image defined as image, and two optional buttons, with topButtonText andbottomButtonText. For example:

你可以设置titleText的属性值,也可以设置subtitleText的属性值,一个你可以控制是否显示的图片,以及两个可选的按钮,你可以分别设置这两个按钮的文本,例如:

notification.titleText = @"Update available";
notification.subtitleText = @"Do you want to download the update of this file?";
notification.image = [UIImage imageNamed:@"update"];
notification.topButtonText = @"Accept";
notification.bottomButtonText = @"Cancel";

If you want to hide the notification by tapping it, set dimissOnTap to YES:

如果你想在点击了通知后隐藏掉通知,你只需要将dimissOnTap设置成YES即可:

notification.dismissOnTap = YES;

To present it, you can choose if you want to use UIKit dynamics (which will include a subtle bounce) or a regular lineal UIKit animation:

为了要显示出通知的view,你可以使用重力感应的属性(这个会包括一个弹跳的效果)或者是普通的UIKit动画效果:

[notification presentInView:self.view withGravityAnimation:YES];

Finally, to handle the buttons taps, implement the two methods defined by the delegate, -dropdownNotificationTopButtonTapped and -dropdownNotificationBottomButtonTapped.

最后,为了能控制按钮事件,实现下面的两个代理方法即可.

-(void)dropdownNotificationTopButtonTapped {

    NSLog(@"Top button tapped");
} -(void)dropdownNotificationBottomButtonTapped { NSLog(@"Bottom button tapped");
}

TODO - 待完成事项

  • Light theme
  • Autolayout support for rotation

License - 协议

AFDropdownNotification is under MIT license so feel free to use it!

Author - 作者

Made by Alvaro Franco. If you have any question, feel free to drop me a line atalvarofrancoayala@gmail.com

[翻译] AFDropdownNotification的更多相关文章

  1. 《Django By Example》第五章 中文 翻译 (个人学习,渣翻)

    书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者@ucag注:大家好,我是新来的翻译, ...

  2. 《Django By Example》第四章 中文 翻译 (个人学习,渣翻)

    书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:祝大家新年快乐,这次带来<D ...

  3. [翻译]开发文档:android Bitmap的高效使用

    内容概述 本文内容来自开发文档"Traning > Displaying Bitmaps Efficiently",包括大尺寸Bitmap的高效加载,图片的异步加载和数据缓存 ...

  4. 【探索】机器指令翻译成 JavaScript

    前言 前些时候研究脚本混淆时,打算先学一些「程序流程」相关的概念.为了不因太枯燥而放弃,决定想一个有趣的案例,可以边探索边学. 于是想了一个话题:尝试将机器指令 1:1 翻译 成 JavaScript ...

  5. 《Django By Example》第三章 中文 翻译 (个人学习,渣翻)

    书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:第三章滚烫出炉,大家请不要吐槽文中 ...

  6. 《Django By Example》第二章 中文 翻译 (个人学习,渣翻)

    书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:翻译完第一章后,发现翻译第二章的速 ...

  7. 《Django By Example》第一章 中文 翻译 (个人学习,渣翻)

    书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:本人目前在杭州某家互联网公司工作, ...

  8. 【翻译】Awesome R资源大全中文版来了,全球最火的R工具包一网打尽,超过300+工具,还在等什么?

    0.前言 虽然很早就知道R被微软收购,也很早知道R在统计分析处理方面很强大,开始一直没有行动过...直到 直到12月初在微软技术大会,看到我软的工程师演示R的使用,我就震惊了,然后最近在网上到处了解和 ...

  9. ASP.NET MVC with Entity Framework and CSS一书翻译系列文章之第一章:创建基本的MVC Web站点

    在这一章中,我们将学习如何使用基架快速搭建和运行一个简单的Microsoft ASP.NET MVC Web站点.在我们马上投入学习和编码之前,我们首先了解一些有关ASP.NET MVC和Entity ...

随机推荐

  1. 关于git远程版本库的一些问题之解决

    Part1:CentOS6.5免密码登录 修改/etc/ssh/sshd_config RSAAuthentication yesPubkeyAuthentication yesAuthorizedK ...

  2. 数组元素的移动(删除) C#实现

    下面有四个问题: 把数组元素前后部分交换 MoveFirstPartOfArrayToTheEnd(int[] array, int index) 比如 {1,2,3,4,5,6,7} 3  => ...

  3. :after伪类+content内容生成经典应用举例——张鑫旭

    一.简单说说content内容生成 content内容生成就是通过content属性生成内容,content属性早在CSS2.1的时候就被引入了,可以使用:before以及:after伪元素生成内容. ...

  4. jQuery 遮盖层弹出后禁止页面滚动

    css部分 .ovfHiden{     overflow: hidden;     height: 100%; }     js部分 $(".btn1").click(funct ...

  5. BZOJ4675: 点对游戏

    传送门 考虑每一对幸运点对的贡献,假设有 \(v\) 对 一共可以选择 \(x\) 个点,总共 \(n\) 个点 那么答案就是 \[v\times\frac{A_{n-2}^{x-2}x(x-1)}{ ...

  6. java.lang.IllegalStateException: Mapped class was not specified

    错误如下:java.lang.IllegalStateException: Mapped class was not specifiedat org.springframework.util.Asse ...

  7. 【canvas系列】canvas实现“ 简单的Amaziograph效果”--画对称图【强迫症福利】

    标题很难引人入胜,先放个效果图好了 如果图片吸引不了你,那我觉得也就没啥看的了. demo链接: https://win7killer.github.io/demo_set/html_demo/can ...

  8. CentOS7.4 + Hadoop2.9安装配置管理(分布式)

    1.  规划 1.1.  机器列表 NameNode SecondaryNameNode DataNodes 192.168.1.121 192.168.1.122 192.168.1.101 192 ...

  9. Spring Boot—16日志设置

    application.properties # server.address=0.0.0.0 server.port=8080 server.servlet.context-path=/test s ...

  10. FineReport中如何实现自动滚屏效果

    对于一些特殊的模板,可能为了展示的更加丰富.全面会在一个页面放置很多图表.表格等内容.由于内容过多,超出了浏览器窗口的大小导致内容展示不全的情况.这样我们就需要用到JS滚屏效果来解决,这里主要介绍在F ...