TWMessageBarManager

简单翻译

https://github.com/terryworona/TWMessageBarManager

An iOS manager for presenting system-wide notifications via a dropdown message bar.

一个iOS的管理类,用来展示系统级别的通知,通过一个下拉的信息条。

Requirements

  • Requires iOS 6.0 or later
  • Requires Automatic Reference Counting (ARC)
  • 需要iOS6.0或以上
  • 需要ARC

Features

  • Drop-in singleton manager supported across all devices.
  • Simple to use protocols and callbacks.
  • Landscape and portrait orientation support.
  • Highly customizable.
  • 单例模式,支持所有的种类的设备
  • 可以使用协议或者block
  • 支持横屏竖屏
  • 高度定制

Refer to the changelog for an overview of TWMessagBarManager's feature history.

Author

Terry Worona

Tweet me @terryworona

Email me at terryworona@gmail.com

Installation

CocoaPods is the recommended method of installing the TWMessageBarManager.

推荐用CocoPods来安装吧。

The Pod Way

Simply add the following line to your Podfile:

pod 'TWMessageBarManager'

Your podfile should look something like:

platform :ios, '6.0'
pod 'TWMessageBarManager', '~> 1.4.0'

The Old School Way

The simpliest way to use TWMessageBarManager with your application is to drag and drop the /Classes folder into you're Xcode 5 project. It's also recommended you rename the /Classes folder to something more descriptive (ie. "TWMessageBarManager").

最简单的方法就是,将这个 TWMessageBarManager 拖入到你的工程项目当中。当然,拖进工程之后,你也需要看看里面文件的一些描述信息。

Usage

Calling the manager

调用这个控制器

As a singleton class, the manager can be accessed from anywhere within your app via the + sharedInstancefunction:

因为他是一个单例,所以,你可以在你的应用程序的任何地方,通过方法 sharedInstance 来调用:

[TWMessageBarManager sharedInstance]

Presenting a basic message

展示一条基本的信息

All messages can be preseted via showMessageWithTitle:description:type:. Additional arguments include duration and callback blocks to be notified of a user tap.

所有的信息都可以通过showMessageWithTitle:description:type:来展示出来,额外的一些参数包括,显示时长,用户点击提示的回调。

Basic message:

基本信息:

[[TWMessageBarManager sharedInstance] showMessageWithTitle:@"Account Updated!"
description:@"Your account was successfully updated."
type:TWMessageBarMessageTypeSuccess];

The default display duration is 3 seconds. You can override this value by supplying an additional argument:

这个默认的显示时间是3s,当然啰,你也可以重写他嘛:

[[TWMessageBarManager sharedInstance] showMessageWithTitle:@"Account Updated!"
description:@"Your account was successfully updated."
type:TWMessageBarMessageTypeSuccess
forDuration:6.0];

Hiding messages

隐藏信息

It's not currently possible to hide or cancel a message on a per-instance basis. Instead, all messages must be canceled at once. This action may or may not be animated:

不大可能立刻为每一个基础信息展示隐藏或者取消掉。相对的,要取消也是所有的信息一起取消,而且是立刻,下面的方法有两种,一种是有动画的取消,一种是没有动画的取消:

[[TWMessageBarManager sharedInstance] hideAllAnimated:YES]; // animated

[[TWMessageBarManager sharedInstance] hideAll]; // non-animated

Callbacks

回调

By default, if a user taps on a message while it is presented, it will automatically dismiss. To be notified of the touch, simply supply a callback block:

默认的,当用户点击到了这条展示的信息,他将会自动消失掉,为了标记这次点击,简单的从一个回调的block中取点击事件就可以了:

[[TWMessageBarManager sharedInstance] showMessageWithTitle:@"Account Updated!"
description:@"Your account was successfully updated."
type:TWMessageBarMessageTypeSuccess callback:^{
NSLog(@"Message bar tapped!");
}];

Queue

队列

The manager is backed by a queue that can handle an infinite number of sequential requests. You can stack as many messages you want on the stack and they will be presetented one after another:

这个控制器也是可以被存储在队列中的咯,这个队列会管理一系列的请求而挨个展示。你可以将你要展示的信息挨个的添加进这个队列中吧。

[[TWMessageBarManager sharedInstance] showMessageWithTitle:@"Message 1"
description:@"Description 1"
type:TWMessageBarMessageTypeSuccess]; [[TWMessageBarManager sharedInstance] showMessageWithTitle:@"Message 2"
description:@"Description 2"
type:TWMessageBarMessageTypeError]; [[TWMessageBarManager sharedInstance] showMessageWithTitle:@"Message 3"
description:@"Description 3"
type:TWMessageBarMessageTypeInfo];

Customization

定制

An object conforming to the TWMessageBarStyleSheet protocol defines the message bar's look and feel:

一个遵守TWMessageBarStyleSheet 协议的对象定义了信息条的样式以及感觉:

+ (UIColor *)backgroundColorForMessageType:(TWMessageBarMessageType)type;
+ (UIColor *)strokeColorForMessageType:(TWMessageBarMessageType)type;
+ (UIImage *)iconImageForMessageType:(TWMessageBarMessageType)type;

If no style sheet is supplied, a default class is provided on initialization. To customize the look and feel of your message bars, simply supply an object conforming to the TWMessageBarStyleSheet protocol via:

如过你没有提供任何的设置样式,它会直接使用默认值。为了定制这个信息条的样式以及感觉,简单的提供一个与协议相关的对象进行一些配置。

@property (nonatomic, weak) id<TWMessageBarStyleSheet> styleSheet;

See TWAppDelegateDemoStyleSheet for an example on how to create a custom stylesheet.

怎么配置呢,不懂的话,请看看那个自定义的demo吧。

使用开源库 TWMessageBarManager 展示系统级别的通知的更多相关文章

  1. 【Eigen开源库】linux系统如何安装使用Eigen库

    code /* * File : haedPose.cpp * Coder: * Date : 20181126 * Refer: https://www.learnopencv.com/head-p ...

  2. 视觉slam十四讲开源库安装教程

    目录 前言 1.Eigen线性代数库的安装 2.Sophus李代数库的安装 3.OpenCV计算机视觉库的安装 4.PCL点云库的安装 5.Ceres非线性优化库的安装 6.G2O图优化库的安装 7. ...

  3. Android强大的开源库与系统架构工具

    后来加上的,因为太强大了,android上百个可立即使用的开源库介绍:https://github.com/Trinea/android-open-project 一款功能强大且实用的开发工具可以为开 ...

  4. iOS5系统API和5个开源库的JSON解析速度测试

    iOS5系统API和5个开源库的JSON解析速度测试 iOS5新增了JSON解析的API,我们将其和其他五个开源的JSON解析库进行了解析速度的测试,下面是测试的结果和工程代码附件. 我们选择的测试对 ...

  5. 这些混账的开源库在煞笔Windows系统上的编译方法

    母语不就是用来吐槽的么!!!!!说母语我不骂人难道还用英语么!!!!!!!!!! 说什么什么开源库好的狗日的,尼玛有种先搞定编译啊卧槽!!!!!!!!! 是的!!!!!你可以吐槽老子智商低用弱智煞笔W ...

  6. 介绍n款计算机视觉库/人脸识别开源库/软件

    计算机视觉库 OpenCV OpenCV是Intel®开源计算机视觉库.它由一系列 C 函数和少量 C++ 类构成,实现了图像处理和计算机视觉方面的很多通用算法. OpenCV 拥有包括 300 多个 ...

  7. iOS 项目中用到的一些开源库和第三方组件

    iOS 项目中用到的一些 iOS 开源库和第三方组件 分享一下我目前所在公司 iOS 项目中用到的一些 iOS 开源库和第三方组件, 感谢开源, 减少了我们的劳动力, 节约了我们大量的时间, 让我们有 ...

  8. Android主流UI开源库整理(转载)

    http://www.jianshu.com/p/47a4a7b99364 标题隐含了两个层面的意思,一个是主流,另一个是UI.主流既通用,一些常规的按钮.Switch.进度条等控件都是通用控件,因此 ...

  9. 【转】深受开发者喜爱的10大Core Data工具和开源库

    http://www.cocoachina.com/ios/20150902/13304.html 在iOS和OSX应用程序中存储和查询数据,Core Data是一个很好的选择.它不仅可以减少内存使用 ...

随机推荐

  1. C#和PHP 长整型时间互转

    //2018/5/14 16:03:05转换:1526284985 public static double ConvertToDouble(DateTime date) { , , )); var ...

  2. Spark(六)Spark之开发调优以及资源调优

    Spark调优主要分为开发调优.资源调优.数据倾斜调优.shuffle调优几个部分.开发调优和资源调优是所有Spark作业都需要注意和遵循的一些基本原则,是高性能Spark作业的基础:数据倾斜调优,主 ...

  3. Solr的入门知识

      一.Solr的简介 Solr 是Apache下的一个顶级开源项目,采用Java开发,它是基于Lucene的全文搜索服务.Solr可以独立运行在Jetty.Tomcat等这些Servlet容器中.都 ...

  4. 【LOJ】#2061. 「HAOI2016」放棋子

    题解 水题,可惜要写高精度有点烦 一看障碍物的摆放方式和最后的答案没有关系,于是干脆不读了,直接二项式反演可以得到 设\(g_k\)为一种摆放方式恰好占了k个障碍物 \(f_k = \sum_{i = ...

  5. 【51nod】1564 区间的价值

    题解 这个要注意到一个长度大的区间的最大价值一定比长度小的区间的价值要大 然后我们以每个点为最小值,显然区间越长最大值越大,然后我们更新最大区间长度的取值,这个可以用单调栈求这个最小值能更新到的左右端 ...

  6. spring配置文件头部配置解析(applicationContext.xml)

    分享一个好的学习网站:http://how2j.cn?p=4509 相信大家对spring的配置文件应该都看的很多了,那么大家对配置文件头部的那一坨坨的东西到底是什么了解吗?下面我就把自己的一些见解和 ...

  7. PHP中CGI,FastCGI,PHP-CGI与PHP-FPM对比

    CGI CGI全称是“公共网关接口”(Common Gateway Interface),HTTP服务器与你的或其它机器上的程序进行“交谈”的一种工具,其程序须运行在网络服务器上. CGI可以用任何一 ...

  8. Java-----jar反编译修改重新打包

    http://blog.csdn.net/hekewangzi/article/details/44676797 一.使用反编译工具JD-GUI(JD-GUI相关操作见Java-----反编译clas ...

  9. 【洛谷】2324:[SCOI2005]骑士精神【IDA*】

    P2324 [SCOI2005]骑士精神 题目描述 输入输出格式 输入格式: 第一行有一个正整数T(T<=10),表示一共有N组数据.接下来有T个5×5的矩阵,0表示白色骑士,1表示黑色骑士,* ...

  10. python开发_tkinter_菜单选项中英文切换_菜单选项不可用操作_博主推荐

    我使用的python版本为:3.3.2 如果你对python中tkinter模块的菜单操作不是很了解,你可以看看: python开发_tkinter_窗口控件_自己制作的Python IDEL_博主推 ...