Git Product home page Git Product logo

ehplainalert's Introduction

EHPlainAlert

This is simple extension for presenting multiple system-wide notifications from bottom of device screen.

Requirements

  • Requires iOS 7.1 or later
  • Requires Automatic Reference Counting (ARC)

##Features

  • Supports multiple messages on one screen
  • Simple use actions
  • Highly customizable
  • Call from anywhere in app

Installation

CocoaPods

To install EHPlainAlert using CocoaPods, please integrate it in your existing Podfile, or create a new Podfile:

platform :ios, '7.1'

target 'MyApp' do
  pod 'EHPlainAlert'
end

Then run pod install.

Usage

#import <EHPlainAlert/EHPlainAlert.h>

Presenting notification

All messages can simply presented via static method call:

[EHPlainAlert showAlertWithTitle:@"Success" message:@"Something works!" type:ViewAlertSuccess];

Messages can be displayed from any location in app, even not associated with UI.

[[NetHelper sharedInstance] postRequestWithURLString:URL data:data withSuccess:^(id responseObject) {
        [EHPlainAlert showAlertWithTitle:@"Success" message:@"Data successfully uploaded" type:ViewAlertSuccess];
    } failure:^(NSError *error)
    {
        [EHPlainAlert showError:error];
    }];

Presenting error notification

For simplifying error handling you can use:

- (void)someError:(NSError *)myError
{
	[EHPlainAlert showError:error];
}

Hiding Messages

Notifications will hidden automatically after 4 seconds.

To change default delay use static method: [EHPlainAlert updateHidingDelay:2.5f];

Also you can just tap on message to hide it.

On Tap Actions

You can change the default behavior for tapping on the notification:

EHPlainAlert * ehAlert = [[EHPlainAlert alloc] initWithTitle:@"Hmm..." message:@"Tap for information" type:ViewAlertInfo];
ehAlert.action = ^{
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://github.com/josshad/EHPlainAlert"]];
};
[ehAlert show];

Customization

Fonts:

Change font of one alert

EHPlainAlert * ehAlert = [[EHPlainAlert alloc] initWithTitle:@"Info" message:@"This is info message" type:ViewAlertInfo];
ehAlert.titleFont = [UIFont fontWithName:@"TrebuchetMS" size:15];
ehAlert.subTitleFont = [UIFont fontWithName:@"TrebuchetMS-Italic" size:12];
[ehAlert show];

Change fonts for alert type

[EHPlainAlert updateTitleFont:[UIFont fontWithName:@"TrebuchetMS" size:18]];
[EHPlainAlert updateSubTitleFont:[UIFont fontWithName:@"TrebuchetMS" size:10]];

Colors:

Change background color of one alert

EHPlainAlert * ehAlert = [[EHPlainAlert alloc] initWithTitle:@"Hmm..." message:@"Blue color alert" type:ViewAlertInfo];
ehAlert.messageColor = [UIColor blueColor];
[ehAlert show];

Change color for alert type

[EHPlainAlert updateAlertColor:[UIColor colorWithWhite:0 alpha:0.5] forType:ViewAlertPanic];

Appearance

[EHPlainAlert updateAlertPosition:ViewAlertPositionTop];

Icons:

Change icon of one alert

EHPlainAlert * ehAlert = [[EHPlainAlert alloc] initWithTitle:@"Hmm..." message:@"Blue color alert" type:ViewAlertInfo];
ehAlert.iconImage = image;
[ehAlert show];

Change icon for alert type

[EHPlainAlert updateAlertIcon:image forType:ViewAlertInfo]; 

Number of messages

[EHPlainAlert updateNumberOfAlerts:4];

Display time

[EHPlainAlert updateHidingDelay:2.5f];

Author

Danila Gusev

[email protected]

License

Usage is provided under the MIT License. See LICENSE for full details.

ehplainalert's People

Contributors

irshadpc avatar josshad avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

ehplainalert's Issues

EHPlainAlert-EHPlainAlert

Command /usr/bin/codesign failed with exit code 1 ..... Works on iPhone device but I get this error when I try to use the simulator.

How to hide the alertview.

Is there a way to automatically hide the alertview based on a button click.

My use case when the user taps on Sign Up button the user is taken to a signup screen, here I am able to see the previous screens alertview. So basically I wanted a method which can hide all the alertviews at once.

Any help much appreciated.

Prefix alert type and alert position with EH*

To avoid conflicts, I propose the following:

typedef enum : NSUInteger {
    EHPlainAlertError,
    EHPlainAlertSuccess,
    EHPlainAlertInfo,
    EHPlainAlertPanic,
    EHPlainAlertUnknown
} EHPlainAlertType;

typedef enum : NSUInteger {
    EHPlainAlertPositionBottom = 0,
    EHPlainAlertPositionTop
} EHPlainAlertPosition;

Multiline alert subtitle issue.

When adding a multi line alert message the Alert Title moves to the top and touches the status bar. I guess the Alert Title label should not move but rather the Alert Subtitle should grow downwards.

Single Line Message

singleline-message

Multi-line Message

multiline-message

number of alerts

is there a way to set up a maximum number of alerts that can be displayed at once?

Icons are not shown (Swift)

I’ve installed your plugin via CocoaPods in Swift project. I’m using such plugin call:

EHPlainAlert.showAlertWithTitle("Title", message: "Error message", type: ViewAlertError)

But default error icon is not shown. I’ve tested with other alert types, but it’s blank space and no default icons.

example

Disable multiple instances.

Hey, your control is great... is it possible though to just have one error displayed at a time and not the multiple errors stacking on screen?

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.