Git Product home page Git Product logo

ahalertview's Introduction

AHAlertView

Overview

AHAlertView is a powerful, block-based alternative to UIKit's UIAlertView. It has the following attractive features:

  1. Block-based button events - no more messy delegate code
  2. UIAppearance conformance to allow easy skinning of all elements
  3. Dramatic presentation and dismissal animations (tumble, fade, zoom, etc.)

Usage Examples

Showing an alert is as simple as creating an alert, adding a button, and calling show:

AHAlertView *alert = [[AHAlertView alloc] initWithTitle:@"Hello, World!" message:@"I'm an alert view!"];
[alert setCancelButtonTitle:@"Dismiss" block:nil];
[alert show];

If a total of two buttons are added, the alert view will lay them out side-by-side:

Two button side-by-side layout example

AHAlertView *alert = [[AHAlertView alloc] initWithTitle:@"Enter Password" message:@"This is a message that might prompt you to do something."];
[alert setCancelButtonTitle:@"Cancel" block:nil];
[alert addButtonWithTitle:@"OK" block:nil];
[alert show];

You can use an alert view to prompt for user input, including secure text for password fields, etc.:

Secure text entry example

AHAlertView *alert = [[AHAlertView alloc] initWithTitle:@"Enter Password" message:@"[email protected]"];
alert.alertViewStyle = AHAlertViewStyleSecureTextInput;
[alert setCancelButtonTitle:@"Cancel" block:^{
	NSLog(@"User canceled the alert instead of entering their password.");
}];
[alert addButtonWithTitle:@"OK" block:^{
	NSLog(@"User entered the password: %@", [alert textFieldAtIndex:0].text);
}];
[alert show];

You can use the block you pass in with the button title to perform any action, including setting a custom dismissal animation based on which button was touched:

Custom theme and animation example

[alert setCancelButtonTitle:@"Cancel" block:^{
    alert.dismissalStyle = AHAlertViewDismissalStyleTumble;
}];

TODO

  • I think we can all agree a little more documentation would be nice.
  • Indeterminate progress style, possibly a determinate one as well.
  • Better button layout code

ahalertview's People

Contributors

mugunthkumar avatar warrenm avatar

Watchers

 avatar  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.