NotificationManager is a stand-alone class that can be used to display notifications to the user similar to the Game Center notifications, but with more features.
- Adjusts to any device orientation
- Customizable duration and several other parameters
- Supports custom icon
- Multi-line text
- 2 different styles: Slide-In and Fade-In
- Supported on iPhone and iPad with iOS 3.2 onwards
-
Add the
QuartzCore
Framework to your Xcode project -
Add the following files to your Xcode project (make sure to select Copy Items in the dialog):
- NotificationManager.h
- NotificationManager.m
- Import the
NotificationManager.h
file
Display a text-only notification:
[[NotificationManager defaultManager] notifyText:@"This is a notification." withStyle:NotificationStyleSlideIn];
Display a notification with specified icon:
[[NotificationManager defaultManager] notifyText:@"This is a notification with an icon." withIcon:@"icon_info.png" withStyle:NotificationStyleSlideIn];
Display notification using Fade-In style:
[[NotificationManager defaultManager] notifyText:@"This is a fade-in notification." withStyle:NotificationStyleFadeIn];
Display notification with custom duration:
[[NotificationManager defaultManager] notifyText:@"This notification is taking too long." withStyle:NotificationStyleFadeIn forDuration:5];
Separate your text with /n
to use multi-line notifications:
[[NotificationManager defaultManager] notifyText:@"This is the first line./nThis is the second line" withStyle:NotificationStyleSlideIn];
Force a notification to any orientation:
[[NotificationManager defaultManager] notifyText:@"This notification is for Landscape (Left) orientation" withStyle:NotificationStyleFadeIn forceOrientation:UIInterfaceOrientationLandscapeLeft];
To customize the look of the notifications, open the NotificationManager.h
file and change the defined constants to alter the font, size and colors.