Latest 1.0.1
Homepage https://github.com/tatowilson/ZTDropDownNotification
License MIT
Platforms ios 8.0
Authors

Carthage compatible
CocoaPods
CocoaPods

ZTDropDownNotification is a notification class that displays a drop-down notification
from top edge of key window and dismisses it after a duration. The default layouts can
display message only or message with icon. It also supports custom layout and displays
custom view directly. The notification is inspired by Mobile QQ, aiming to provide a
handy way to show notifications.

ZTDropDownNotification

Requirements

ZTDropDownNotification works on iOS 8+. It depends on the following Apple frameworks, which should already be included with most Xcode templates:

  • Foundation.framework
  • UIKit.framework

You will need the latest developer tools in order to build ZTDropDownNotification. Old Xcode versions might work, but compatibility will not be explicitly maintained.

CocoaPods

  1. Add pod 'ZTDropDownNotification' to your Podfile.
  2. Install the pod(s) by running pod install.
    1. For Swift project:
      Import ZTDropDownNotification wherever you need it with import ZTDropDownNotification
    2. For Objective-C project:
      Include ZTDropDownNotification wherever you need it with #import "ZTDropDownNotification.h".

Usage

Notify Message Only

Swift:

  ZTDropDownNotification.notifyMessage("content", withIcon: nil)

Ojbective-C:

  [ZTDropDownNotification notifyMessage:@"content" withIcon:nil];

Shortcut Notifying Messages

Shortcut notifying methods use ZTNInfoIconKey, ZTNSuccessIconKey and ZTNFailureIconKey to get corresponding icon.

For example, register ZTNSuccessIconKey icon as following:

Swift:

  ZTDropDownNotification.registerIcons([
      ZTNSuccessIconKey: #imageLiteral(resourceName:"check_green")])

Ojbective-C:

  [ZTDropDownNotification registerIcons:@{
      ZTNSuccessIconKey: [UIImage imageNamed:@"check_green"]
      }];

And then notifySuccessMessage: method works as expected:

Swift:

  ZTDropDownNotification.notifySuccessMessage("content")

Ojbective-C:

  [ZTDropDownNotification notifySuccessMessage:@"content"];

Note:
It will "notify message only" if the corresponding icon isn’t registered before.

Notify Message with Custom Registered Icon

Swift:

  ZTDropDownNotification.notifyMessage("content", withIconKey: "ExampleIconKey")

Ojbective-C:

  [ZTDropDownNotification notifyMessage:@"content" withIconKey:@"ExampleIconKey"];

Notify Message with Temporary Icon

Swift:

  ZTDropDownNotification.notifyMessage("content", withIcon: #imageLiteral(resourceName:"thumbs_up_blue"))

Ojbective-C:

  [ZTDropDownNotification notifyMessage:@"content" withIcon:[UIImage imageNamed:@"thumbs_up_blue"]];

Set Custom Layout as Default Layout

Swift:

  ZTDropDownNotification.setCustomLayoutGenerator { () -> UIView in
      return CustomLayout.init()
    }

Ojbective-C:

  [ZTDropDownNotification setCustomLayoutGenerator:^UIView <ZTNLayout> * {
    return [CustomLayout new];
  }];

Note:
Due to current implementation(1.0.0), custom layout and view should leave an extra 8pt height area on top of the real content area.

Reset to Built-in Layouts

Swift:

  ZTDropDownNotification.setCustomLayoutGenerator(nil)

Ojbective-C:

  [ZTDropDownNotification setCustomLayoutGenerator:nil];

Notify Custom Temporary View

Swift:

  ZTDropDownNotification.notify(view)

Ojbective-C:

  [ZTDropDownNotification notifyView:view];

Note:
Due to current implementation(1.0.0), custom layout and view should leave an extra 8pt height area on top of the real content area.

TODO

  • [ ] Add unit tests.
  • [ ] Integrate Travis CI.
  • [ ] Find a better solution to avoid the spring animation on the top edge when the view shows totally.
  • [x] Support Swift.

License

Released under MIT license.

Latest podspec

{
    "name": "ZTDropDownNotification",
    "version": "1.0.1",
    "summary": "An iOS drop-down notification.",
    "description": "ZTDropDownNotification is a notification class that displays a drop-down notificationnfrom top edge of key window and dismisses it after a duration. The default layouts canndisplay message only or message with icon. It also supports custom layout and displaysncustom view directly. The notification is inspired by Mobile QQ, aiming to provide anhandy way to show notifications.",
    "homepage": "https://github.com/tatowilson/ZTDropDownNotification",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Zhang Tao": "[email protected]"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/tatowilson/ZTDropDownNotification.git",
        "tag": "1.0.1"
    },
    "source_files": "*.{h,m}"
}

Pin It on Pinterest

Share This