TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Aug 2017 |
Maintained by Zhang Tao.
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
works on iOS 8+. It depends on the following Apple frameworks, which should already be included with most Xcode templates:
You will need the latest developer tools in order to build ZTDropDownNotification
. Old Xcode versions might work, but compatibility will not be explicitly maintained.
Swift:
ZTDropDownNotification.notifyMessage("content", withIcon: nil)
Ojbective-C:
[ZTDropDownNotification notifyMessage:@"content" withIcon:nil];
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.
Swift:
ZTDropDownNotification.notifyMessage("content", withIconKey: "ExampleIconKey")
Ojbective-C:
[ZTDropDownNotification notifyMessage:@"content" withIconKey:@"ExampleIconKey"];
Swift:
ZTDropDownNotification.notifyMessage("content", withIcon: #imageLiteral(resourceName:"thumbs_up_blue"))
Ojbective-C:
[ZTDropDownNotification notifyMessage:@"content" withIcon:[UIImage imageNamed:@"thumbs_up_blue"]];
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.
Swift:
ZTDropDownNotification.setCustomLayoutGenerator(nil)
Ojbective-C:
[ZTDropDownNotification setCustomLayoutGenerator:nil];
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.
Released under MIT license.