EMNotificationPopup 0.3.0

EMNotificationPopup 0.3.0

TestsTested
LangLanguage Obj-CObjective C
License Custom
ReleasedLast Release Mar 2016

Maintained by Ennio Masi.



ENotificationPopup

EMNotificationPopup is a customizable, easy and ready to use notification Popup with nice animations.

  • Built to be Universal
  • Uses ARC (Automatic Reference Counting)
  • Support iOS > 6.0
  • T reusable component

How to install it?

Source Code

Alternatively you can just copy all the files included in the folder EMNotificationPopup and start playing with it!

How it works?

EMNotificationPopup Class

@interface EMNotificationPopup : UIView

@property NSObject <EMNotificationPopupDelegate> *delegate;

@property (nonatomic, strong) NSString *actionTitle;
@property (nonatomic, strong) UIImage *image;
@property (nonatomic, strong) NSString *subtitle;
@property (nonatomic, strong) NSString *title;

// Init default View
- (id) initWithType: (EMNotificationPopupType) type enterDirection:(EMNotificationPopupDirection) enter exitDirection:(EMNotificationPopupDirection) exit popupPosition: (EMNotificationPopupPosition) position;

// Init custom view
- (id) initWithView:(UIView *)view enterDirection:(EMNotificationPopupDirection) enter exitDirection:(EMNotificationPopupDirection) exit popupPosition: (EMNotificationPopupPosition) position;

// Actions on the popup view
- (void) dismissWithAnimation:(BOOL) animate;
- (void) show;
- (BOOL) isVisible;

// (new in 0.2.2) Customize the bounce power
- (void) setBouncePower:(NSInteger) bouncePower;

// Customize the default view
- (void) setPopupActionBackgroundColor: (UIColor *) color;
- (void) setPopupActionTitleColor: (UIColor *) color;
- (void) setPopupBorderColor: (UIColor *)color;
- (void) setPopupBackgroundColor:(UIColor *)color;
- (void) setPopupSubtitleColor:(UIColor *)color;
- (void) setPopupTitleColor:(UIColor *)color;
@end

EMNotificationPopupDelegate Protocol

@protocol EMNotificationPopupDelegate
- (void) emNotificationPopupActionClicked;
@end

How to use it?

Example - Use the default popup view

    EMNotificationPopup *notificationPopup = [[EMNotificationPopup alloc] initWithImage:[UIImage imageNamed:@"alert_image"] andTitle:@"Hi, this is an alert message!" andSubTitle:@"Sorry for this message :)" andButtonTitle:@"OK"];
    notificationPopup.delegate = self;
    [notificationPopup showWithEnterDirection:EMNotificationPopupToDown andExitDirection:EMNotificationPopupToLeft];

Example - Use default views

An example about the use of a "Big" Notification Popup. This is a big (taller than larger) notification that is able to show an image, a title and a subtitle. If you instantiate a EMNotificationPopupBigButton you can customize the action button title and color. This button is used to dismiss the view.

    _notificationPopup = [[EMNotificationPopup alloc] initWithType:notificationPopupType enterDirection:EMNotificationPopupToDown exitDirection:EMNotificationPopupToLeft popupPosition:position];
    _notificationPopup.delegate = self;

    _notificationPopup.title = @"Sorry for this Alert message :)";
    _notificationPopup.subtitle = @"Awesome message :)";
    _notificationPopup.image = [UIImage imageNamed:@"alert_image"];

    if (notificationPopupType == EMNotificationPopupBigButton)
        _notificationPopup.actionTitle = @"OK";

    [_notificationPopup show];

An example about the use of a "Slim" Notification Popup. This is a slim rectangular notification that is able to show just a title.

    _notificationPopup = [[EMNotificationPopup alloc] initWithType:EMNotificationPopupSlim enterDirection:EMNotificationPopupToDown exitDirection:EMNotificationPopupToLeft popupPosition:position];
    _notificationPopup.delegate = self;

    _notificationPopup.title = @"Sorry for this Alert message :)";

    [_notificationPopup show];

Both views can be easily customized using the following methods:

- (void) setPopupActionBackgroundColor: (UIColor *) color;
- (void) setPopupActionTitleColor: (UIColor *) color;
- (void) setPopupBorderColor: (UIColor *)color;
- (void) setPopupBackgroundColor:(UIColor *)color;
- (void) setPopupSubtitleColor:(UIColor *)color;
- (void) setPopupTitleColor:(UIColor *)color;

Example - Use a custom view

    UIView *shownView = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 250.0f, 125.0f)];
    shownView.backgroundColor = [UIColor redColor];

    UIButton *closeMe = [[UIButton alloc] initWithFrame:CGRectMake(shownView.frame.size.width - 25.0f, 3.0f, 22.0f, 22.0f)];
    closeMe.backgroundColor = [UIColor clearColor];
    [closeMe setBackgroundImage:[UIImage imageNamed:@"close"] forState:UIControlStateNormal];
    [closeMe addTarget:self action:@selector(dismissMe) forControlEvents:UIControlEventTouchDown];
    [shownView addSubview:closeMe];

    _notificationPopup = [[EMNotificationPopup alloc] initWithView:shownView enterDirection:EMNotificationPopupToRight exitDirection:EMNotificationPopupToRight popupPosition:position];
    _notificationPopup.delegate = self;

    [_notificationPopup show];

Apps using EMNotificationPopup

Twists&Turns

My Soldier for Battlefield 4 Smartcomix

Help me improving this!

How? Simply feel free to fork the project and improve it!

If you would like to contact me: Twitter: ennioma. Email: [email protected]