Skip to content

Commit

Permalink
Updated README
Browse files Browse the repository at this point in the history
  • Loading branch information
Collin Ruffenach committed Dec 3, 2013
1 parent 6f93011 commit 6b3f784
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 64 deletions.
108 changes: 44 additions & 64 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,96 +1,78 @@
# CWStatusBarNotification

`CWStatusBarNotification` is a library that allows you to easily create text-based notifications that appear on the status bar.
`CWStatusBarNotification` is a library that allows you to easily create notifications that appear on the status bar.

![demo](screenshots/demo.gif)

## Requirements

`CWStatusBarNotification` uses ARC and requires iOS 7.0+.

Works for iPhone and iPad.
`CWStatusBarNotification` uses ARC and requires iOS 7.0+. Works for iPhone and iPad.

## Installation

### CocoaPods

`pod 'CWStatusBarNotification', '~> 2.1.0'`
`pod 'CWStatusBarNotification', '~> 3.0'`

### Manual

Copy the folder `CWStatusBarNotification` to your project.

## Usage

***Note:** The previous version of this library implemented the notifications using a category. This version uses an object instead.*

Firstly, you need the following import statement:

```
#import "CWStatusBarNotification.h"
Notifications can be created through `CWStatusBarNotificationManager`'s `showNotificationWithOptions:completionBlock:` This will queue up a notification with the options specified. You provide options for your notification in a dictionary using the keys in `CWStatusBarNotification.h`

#### Example
This code

``` objc
NSDictionary *options = @{kCWStatusBarNotificationTextKey : @"Hello World!",
kCWStatusBarNotificationTextAlignmentKey : @(NSTextAlignmentCenter),
kCWStatusBarNotificationBackgroundColorKey : [UIColor redColor],
kCWStatusBarNotificationAnimationTypeKey : @(CWStatusBarNotificationAnimationTypeSpring),
kCWStatusBarNotificationNotificationInAnimationStyleKey : @(CWStatusBarNotificationAnimationStyleLeft),
kCWStatusBarNotificationNotificationOutAnimationStyleKey : @(CWStatusBarNotificationAnimationStyleRight),
kCWStatusBarNotificationAnimateInTimeIntervalKey : @(0.5),
kCWStatusBarNotificationAnimateOutTimeIntervalKey: @(0.5)};
[CWStatusBarNotificationManager showNotificationWithOptions:options
completionBlock:^{
NSLog(@"Completed");
}];
```
Generates this
Now, you need to create a `CWStatusBarNotification` object. It is recommended that you do so by attaching it as a property to a `UIViewController`.
![](screenshots/red_notification.gif)
```
CWStatusBarNotification *notification = [CWStatusBarNotification new];
```
After you have a `CWStatusBarNotification` object, you can simply call the `displayNotificationMessage:forDuration:` method:
```
[self.notification displayNotificationWithMessage:@"Hello, World!"
forDuration:1.0f];
```

If you prefer to manually choose when to display and dismiss the notification, you can do so as well:
## Customization
```
[self.notification displayNotificationWithMessage:@"Hello" completion:nil];
// wait until you need to dismiss
[self.notofication dismissNotification];
```
`CWStatusBarNotification` is very customizable. Taking a hint from `UIStringDrawing`'s `drawInRect:withAttributes:` book, notifications are created with dictionaries filled with all their options.
## Customizing Appearance
### Customizing Appearance
First of all, you can customize the background color and text color using the following properties: `notificationLabelBackgroundColor` and `notificationLabelTextColor`.
`CWStatusBarNotification` allows for setting of
Example:
- Alert Text
- Text Color
- Text Font
- Text Alignment
- Text Color
- Text Shadow Color
- Text Shadow Offset
- Left aligned image
```
notification.notificationLabelBackgroundColor = [UIColor blackColor];
notification.notificationLabelTextColor = [UIColor greenColor];
```
### Customizing Animation
![custom colors](screenshots/ss1.gif)
`CWStatusBarNotification` also allows for animation customization. This includes.
The default value of `notificationLabelBackgroundColor` is `[[UIApplication sharedApplication] delegate].window.tintColor`.
- Animation Type (Linear or Spring)
- Presentation Type (Slide over bars or push content out)
- Direction (Enter and exit in any direction)
- Enter, Stay on Screen and Exit Timing
The default value of `notification.notificationLabelTextColor` is `[UIColor whiteColor]`.
### Setting Defaults
Finally, you can also choose from two styles - a notification the size of the status bar, or a notification the size of the status bar and a navigation bar. Simply change the `notificationStyle` property of the `CWStatusBarNotification` object to either `CWNotificationStyleStatusBarNotification` or `CWNotificationStyleNavigationBarNotification`.

![custom style](screenshots/ss2.gif)

The default value of `notificationStyle` is `CWNotificationStyleStatusBarNotification`.

## Customizing Animation

There are two properties that determine the animation style of the notification: `notificationAnimationInStyle` and `notificationAnimationOutStyle`. Each can take on one of four values:

* `CWNotificationAnimationStyleTop`
* `CWNotificationAnimationStyleBottom`
* `CWNotificationAnimationStyleLeft`
* `CWNotificationAnimationStyleRight`

The `notificationAnimationInStyle` describes where the notification comes from, whereas the `notificationAnimationOutStyle` describes where the notification will go.

The default value for `notificationAnimationInStyle` is `CWNotificationAnimationStyleTop`.

The default value for `notificationAnimationOutStyle` is `CWNotificationAnimationStyleTop`.

### Additional Remarks

The notifications will work in both screen orientations, however, screen rotation while a notification is displayed is not yet fully supported.
There are sane defaults set for all properties, however you can set a default set of options for your application's notifications using `CWStatusBarNotificationManagers`'s `setDefaultOptions:`.
## License
Expand All @@ -114,6 +96,4 @@ The notifications will work in both screen orientations, however, screen rotatio
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.


THE SOFTWARE.
Binary file modified screenshots/demo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/red_notification.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed screenshots/screenshot.png
Binary file not shown.
Binary file removed screenshots/ss1.gif
Binary file not shown.
Binary file removed screenshots/ss2.gif
Binary file not shown.

0 comments on commit 6b3f784

Please sign in to comment.