3 Star 0 Fork 0

Gitee 极速下载 / twmessagebarmanager

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/terryworona/TWMessageBarManager
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

TWMessageBarManager

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

Requirements

  • Requires iOS 6.0 or later
  • Requires Automatic Reference Counting (ARC)

Features

  • Drop-in singleton manager supported across all devices.
  • Simple to use protocols and callbacks.
  • Landscape and portrait orientation support.
  • Highly customizable.

Refer to the <a href="https://github.com/terryworona/TWMessageBarManager/blob/master/CHANGELOG.md"">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.

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'

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").

Usage

Calling the manager

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

[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.

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:

[[TWMessageBarManager sharedInstance] showMessageWithTitle:@"Account Updated!"
                                               description:@"Your account was successfully updated."
                                                      type:TWMessageBarMessageTypeSuccess
                                                  duration: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:

[[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];

UIStatusBarStyle

The manager utilizes a custom UIWindow & UIViewController to manage orientation. For targets >= iOS7, if a UIStatusBarStyle other than UIStatusBarStyleDefault is desired, simply call:

- (void)showMessageWithTitle:(NSString *)title description:(NSString *)description type:(TWMessageBarMessageType)type statusBarStyle:(UIStatusBarStyle)statusBarStyle callback:(void (^)())callback;

If a message is presented with a custom UIStatusBarStyle, after dismissal, the status bar will revert back to the the system style (that of the current UIVIewController).

If you wish to hide the status bar altogether during presentations, you can do so via:

- (void)showMessageWithTitle:(NSString *)title description:(NSString *)description type:(TWMessageBarMessageType)type statusBarHidden:(BOOL)statusBarHidden callback:(void (^)())callback;

Customization

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

@required

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

@optional

- (UIFont *)titleFontForMessageType:(TWMessageBarMessageType)type;
- (UIFont *)descriptionFontForMessageType:(TWMessageBarMessageType)type;
- (UIColor *)titleColorForMessageType:(TWMessageBarMessageType)type;
- (UIColor *)descriptionColorForMessageType:(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.

License

Usage is provided under the MIT License. See LICENSE for full details.

Copyright (C) 2013 Terry Worona Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software" ), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

暂无描述 展开 收起
Objective-C 等 2 种语言
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/mirrors/twmessagebarmanager.git
git@gitee.com:mirrors/twmessagebarmanager.git
mirrors
twmessagebarmanager
twmessagebarmanager
master

搜索帮助