Giter VIP home page Giter VIP logo

alalertbanner's Introduction

ALAlertBanner

About

ALAlertBanner is a drop-in library for iOS (both iPhone and iPad) that presents beautiful alert banners in a customizable and configurable way.

Preview

Preview1 Preview2

Preview3

Behind the Scenes

ALAlertBanner uses Core Animation and Grand Central Dispatch under the hood, making it lightweight and stable. A singleton object is used to manage the presentation and dismissal of the alerts in a synchronous manner.

Installation

Installation is easy.

  1. Download the ZIP from Github and copy the ALAlertBanner directory to your project
  2. Link the QuartzCore.framework library in your project's Build Phases
  3. #import "ALAlertBanner.h" in your view of choice

If you can compile without errors, congratulations! You're one step closer to...

(•_•)

( •_•)>⌐■-■

(⌐■_■)

...being cool.

Tested Environments

ALAlertBanner has been tested on iOS 5.0 and 5.1 (simulator) and iOS 6.1 (device) with ARC enabled. It should work in older/newer versions/devices, but I'm not positive.

Example Usage

You should use the ALAlertBannerManager singleton object to manage all banners. You can easily present a banner in a regular UIView like so:

[[ALAlertBannerManager sharedManager] showAlertBannerInView:self.view 
                                      style:ALAlertBannerStyleSuccess 
                                      position:ALAlertBannerPositionTop 
                                      title:@"Success!"
                                      subtitle:@"Here's a banner. Look how easy that was."];

or in a UIWindow:

AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
[[ALAlertBannerManager sharedManager] showAlertBannerInView:appDelegate.window 
                                      style:ALAlertBannerStyleNotify 
                                      position:ALAlertBannerPositionUnderNavBar 
                                      title:@"Notify!"
                                      subtitle:@"Here's another banner, and it is nice and comfy in its UIWindow"];

A couple notes: title is limited to one line and will be truncated if necessary. subtitle can be any number of lines, or it can also be nil. All other parameters should be used however.

Other methods of consideration:

-(void)hideAllAlertBanners;

Immediately hide all alert banners.

-(void)hideAlertBannersInView:(UIView*)view;

Immediately hide all alert banners within a specific view.

Properties

Note: ALL properties should be set through ALAlertBannerManager like so:

[[ALAlertBannerManager sharedManager] setProperty:0.f];

End Note


ALAlertBannerManager has the following editable properties:

/**
 Length of time in seconds that a banner should show before auto-hiding. Default is 3.5 seconds. A value <= 0 will disable auto-hiding. 
 */
@property (nonatomic) NSTimeInterval secondsToShow;

/**
 The length of time it takes a banner to transition on-screen. Default is 0.25 seconds.
 */
@property (nonatomic) NSTimeInterval showAnimationDuration;

/**
 The length of time it takes a banner to transition off-screen. Default is 0.2 seconds.
 */
@property (nonatomic) NSTimeInterval hideAnimationDuration;

/**
 Banner opacity, between 0 and 1. Default value is 0.93f.
 */
@property (nonatomic, assign) CGFloat bannerOpacity;

/**
 Tapping on a banner will dismiss it early. Default is YES.
 */
@property (nonatomic, assign) BOOL allowTapToDismiss;

Banner Positions

ALAlertBannerPositionTop = 0

The banner will be extend down from the top of the screen. If you're presenting it in a:

  • UIView: the banner will extend down from underneath the status bar (if visible)

  • UIView within a UINavigationController: it will extend down from underneath the navigation bar

  • UIWindow: it should extend down from underneath the status bar but above any other UI elements, like the nav bar for instance

ALAlertBannerPositionBottom

The banner will be extend up from the bottom of the screen.

ALAlertBannerPositionUnderNavBar

This position should ONLY be used if presenting in a UIWindow. It will create an effect similar to ALAlertBannerPositionTop on a UIView within a UINavigationController (i.e. extending down from underneath the navigation bar), but it will in fact be above all other views. It accomplishes this by using a CALayer mask. This position is useful if you want to do something like set up a "catch-all" error handler in your AppDelegate that responds to notifications about a certain event (like network requests, for instance), yet you still want it to animate from underneath the nav bar.

Banner Types

ALAlertBannerStyleSuccess = 0

The banner will have a cute little checkmark and a nice green gradient.

ALAlertBannerStyleFailure

The banner will have a cute little X and a nice red gradient.

ALAlertBannerStyleNotify

The banner will have a cute little info symbol and a nice blue gradient.

ALAlertBannerStyleAlert

The banner will have a cute little caution triangle and a nice yellow gradient.

Did I mention they have cute little shapes and nice colorful gradients?

Known Issues

  • FIXED ALAlertBanner supports all interface orientations. However, if you rotate the device while one or more banners is displaying (or animating), the layout will get fudgesicled. This is just something I haven't figured out how to fix yet.
  • If you find any other bugs, please open a new issue.

Contact Me

You can reach me anytime at the addresses below. If you use the library, feel free to give me a shoutout on Twitter to let me know how you like it. I'd love to hear your thoughts.

Github: alobi
Twitter: @lobi4nco
Email: [email protected]

Credits & License

ALAlertBanner is developed and maintained by Anthony Lobianco (@lobi4nco). Licensed under the MIT License. Basically, I would appreciate attribution if you use it.

Enjoy!

(⌐■_■)

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.