[翻译] AFDropdownNotification
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
最新文章
- Dertouzos (5750)
- 代码提交的时候可以插入表情了-GitHub表情的使用
- C堆栈入门
- [Top-Down Approach] Assignment 1: WebServer [Python]
- android listView Exception
- The state of binary data in the browser
- BASH_SOURCE 用法
- Kolor Neutralhazer v1.0.2 (照片雾气模糊去除过滤器)+破解RI
- 【精度问题】【HDU2899】Strange fuction
- 比较不熟的JavaScript点滴,慢慢前行,附带简单复杂化的php小计算器一份
- 【原创】Android 5.0 BLE低功耗蓝牙从设备应用
- Java 线程的生命周期
- Flask 中的路由系统
- Bugly实现app全量更新
- 转载 R语言颜色基础设置
- jdk8-stream的api
- 腾讯云Centos安装jdk8
- CPP_类默认函数:构造函数,拷贝构造函数,赋值函数和析构函数
- spring boot 使用静态资源
- Ubuntu用户管理
热门文章
- redis-springdata-api
- 《Head First 设计模式》读后总结:基础,原则,模式
- C语言----<;另类>;神奇的";Hello World!";
- volatile特性
- Guidlines and rules About Overwriting hashCode()
- windows主机网络信息获取程序设计
- 解决:maven 项目添加 pom 的 oracle 依赖
- 解决文字和text-decoration:underline下划线重叠问题
- Centos7宽带连接
- Linux排查Java程序占用CPU很高的解决办法