Code Monkey home page Code Monkey logo

emnotificationpopup's Introduction

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?

CocoaPods

The recommended approach is to install EMNotificationPopup via CocoaPods.

platform :ios, '6.0'
pod 'EMNotificationPopup', '~> 0.2'

And then install running

$ pod install

And now open the project in Xcode from the .xcworkspace file, not from the project file

$ open YourOwnProject.xcworkspace

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;

// 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

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]

emnotificationpopup's People

Contributors

ennioma avatar nable avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.