Compare commits

...

5 Commits

Author SHA1 Message Date
Cezary Wojcik 23a64f768d 2.3.1
custom notification animation duration
2015-07-11 14:49:01 -07:00
Cezary Wojcik e3fd1677b1 CGFloat -> NSTimeInterval 2015-07-11 14:44:27 -07:00
Cezary Wojcik dfbb1ed5f6 no need for this because of PCH 2015-07-11 14:42:07 -07:00
Cezary Wojcik 71aec53e1d updated read 2015-07-11 14:38:22 -07:00
Cezary Wojcik a24706854d added one more doc comment 2015-07-11 14:35:51 -07:00
4 changed files with 24 additions and 16 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "CWStatusBarNotification"
s.version = "2.3.0"
s.version = "2.3.1"
s.summary = "A library that creates status bar notifications."
s.description = "CWStatusBarNotification is a library allows you to present a beautiful text-based notification in the status bar."
s.homepage = "https://github.com/cezarywojcik/CWStatusBarNotification"
@@ -6,8 +6,6 @@
// Copyright (c) 2015 Cezary Wojcik. All rights reserved.
//
#import <Foundation/Foundation.h>
/**
* @brief A simple completion used for handling tapping the notification.
*/
@@ -20,6 +18,10 @@ typedef void(^CWCompletionBlock)(void);
* label.
*/
@interface ScrollLabel : UILabel
/**
* Used to find the amount of time that the label will spend scrolling.
* @return The amount of time that will be spent scrolling.
*/
- (CGFloat)scrollTime;
@end
@@ -145,6 +147,11 @@ typedef NS_ENUM(NSInteger, CWNotificationAnimationType) {
* @c UIInterfaceOrientationMaskAll.
*/
@property (nonatomic) UIInterfaceOrientationMask supportedInterfaceOrientations;
/**
* The amount of time that it takes to animate the notification in or out.
* Default value is 0.25.
*/
@property (nonatomic) NSTimeInterval notificationAnimationDuration;
/**
* Determines whether the notification covers the status bar or both the status
* bar and the navigation bar. Default value is
@@ -196,7 +203,7 @@ typedef NS_ENUM(NSInteger, CWNotificationAnimationType) {
* not including the animate in and out times.
*/
- (void)displayNotificationWithMessage:(NSString *)message
forDuration:(CGFloat)duration;
forDuration:(NSTimeInterval)duration;
/**
* Displays a notification with the indicated attributed string and then
@@ -221,7 +228,7 @@ typedef NS_ENUM(NSInteger, CWNotificationAnimationType) {
*/
- (void)displayNotificationWithAttributedString:(NSAttributedString *)
attributedString
forDuration:(CGFloat)duration;
forDuration:(NSTimeInterval)duration;
/**
* Displays a notification with the indicated custom view and then performs the
@@ -245,7 +252,7 @@ typedef NS_ENUM(NSInteger, CWNotificationAnimationType) {
* not including the animate in and out times.
*/
- (void)displayNotificationWithView:(UIView *)view
forDuration:(CGFloat)duration;
forDuration:(NSTimeInterval)duration;
/**
* Dismisses the currently presented notification and then performs the
@@ -11,13 +11,11 @@
#define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define STATUS_BAR_ANIMATION_LENGTH 0.25f
#define FONT_SIZE 12.0f
#define PADDING 10.0f
#define SCROLL_SPEED 40.0f
#define SCROLL_DELAY 1.0f
# pragma mark - ScrollLabel
@implementation ScrollLabel
@@ -203,6 +201,7 @@ static void cancel_delayed_block(CWDelayedBlockHandle delayedHandle)
self.customView = nil;
self.multiline = NO;
self.supportedInterfaceOrientations = UIInterfaceOrientationMaskAll;
self.notificationAnimationDuration = 0.25;
self.notificationStyle = CWNotificationStyleStatusBarNotification;
self.notificationAnimationInStyle = CWNotificationAnimationStyleBottom;
self.notificationAnimationOutStyle = CWNotificationAnimationStyleBottom;
@@ -489,7 +488,7 @@ static void cancel_delayed_block(CWDelayedBlockHandle delayedHandle)
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateStatusBarFrame) name:UIApplicationWillChangeStatusBarFrameNotification object:nil];
// animate
[UIView animateWithDuration:STATUS_BAR_ANIMATION_LENGTH animations:^{
[UIView animateWithDuration:self.notificationAnimationDuration animations:^{
[self firstFrameChange];
} completion:^(BOOL finished) {
double delayInSeconds = [self.notificationLabel scrollTime];
@@ -500,7 +499,7 @@ static void cancel_delayed_block(CWDelayedBlockHandle delayedHandle)
}
}
- (void)displayNotificationWithMessage:(NSString *)message forDuration:(CGFloat)duration
- (void)displayNotificationWithMessage:(NSString *)message forDuration:(NSTimeInterval)duration
{
[self displayNotificationWithMessage:message completion:^{
self.dismissHandle = perform_block_after_delay(duration, ^{
@@ -515,7 +514,7 @@ static void cancel_delayed_block(CWDelayedBlockHandle delayedHandle)
[[self notificationLabel] setAttributedText:attributedString];
}
- (void)displayNotificationWithAttributedString:(NSAttributedString *)attributedString forDuration:(CGFloat)duration
- (void)displayNotificationWithAttributedString:(NSAttributedString *)attributedString forDuration:(NSTimeInterval)duration
{
[self displayNotificationWithMessage:[attributedString string] forDuration:duration];
[[self notificationLabel] setAttributedText:attributedString];
@@ -549,7 +548,7 @@ static void cancel_delayed_block(CWDelayedBlockHandle delayedHandle)
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateStatusBarFrame) name:UIApplicationWillChangeStatusBarFrameNotification object:nil];
// animate
[UIView animateWithDuration:STATUS_BAR_ANIMATION_LENGTH animations:^{
[UIView animateWithDuration:self.notificationAnimationDuration animations:^{
[self firstFrameChange];
} completion:^(BOOL finished) {
[completion invoke];
@@ -557,7 +556,7 @@ static void cancel_delayed_block(CWDelayedBlockHandle delayedHandle)
}
}
- (void)displayNotificationWithView:(UIView *)view forDuration:(CGFloat)duration
- (void)displayNotificationWithView:(UIView *)view forDuration:(NSTimeInterval)duration
{
[self displayNotificationWithView:view completion:^{
self.dismissHandle = perform_block_after_delay(duration, ^{
@@ -572,7 +571,7 @@ static void cancel_delayed_block(CWDelayedBlockHandle delayedHandle)
cancel_delayed_block(self.dismissHandle);
self.notificationIsDismissing = YES;
[self secondFrameChange];
[UIView animateWithDuration:STATUS_BAR_ANIMATION_LENGTH animations:^{
[UIView animateWithDuration:self.notificationAnimationDuration animations:^{
[self thirdFrameChange];
} completion:^(BOOL finished) {
UIView *view = self.isCustomView ? self.customView : self.notificationLabel;
+4 -2
View File
@@ -2,10 +2,12 @@
[![Build Status](https://travis-ci.org/cezarywojcik/CWStatusBarNotification.png?branch=master)](https://travis-ci.org/cezarywojcik/CWStatusBarNotification)
**NOTE:** You can find a `Swift` implementation of this library [in the swift branch of this repo](https://github.com/cezarywojcik/CWStatusBarNotification/tree/swift).
**NOTE:** You can find a `Swift` implementation of this library [in the swift branch of this repo](https://github.com/cezarywojcik/CWStatusBarNotification/tree/swift). This version is currently somewhat outdated, but a new one with Swift 2.0 will be coming soon!
`CWStatusBarNotification` is a library that allows you to easily create text-based notifications that appear on the status bar.
You can find the documentation [here](http://cocoadocs.org/docsets/CWStatusBarNotification/).
![demo](screenshots/demo.gif)
## Requirements
@@ -18,7 +20,7 @@ Works for iPhone and iPad.
### CocoaPods
`pod 'CWStatusBarNotification', '~> 2.3.0'`
`pod 'CWStatusBarNotification', '~> 2.3.1'`
### Manual