Git Product home page Git Product logo

urbnalert's Introduction

CI Status Version License Platform

URBNAlert

enter image description hereenter image description hereenter image description hereenter image description here

URBNAlert is a customizable alert view based on iOS's UIAlertController.

UIAlertController was a great improvement over UIAlertView, but you still cannot apply custom fonts, colors, or other styles to the alerts. URBNAlert gives you that flexibility.

You can also pass custom UIView's into a URBNAlert, and create passive alerts with no buttons that dismiss after a period of time.

Usage

After adding URBNALERT to your projects Podfile, import URBNAlert using the following import line:

#import <URBNAlert/URBNAlert.h>

Checkout & run the pod's example project to see what URBNAlert is capable of.

Special Note: To support background blur on iPhone 6 or 6+, you need to include a Launch image or xib that supports those devices.

During blurring of the background, there seems to be an issue with Apple’s drawViewHierarchyInRect:afterScreenUpdates: when afterScreenUpdates = YES. If no launch image or xib is supplied for the iPhone 6 or 6+, drawViewHierarchyInRect:afterScreenUpdates: will resize the view briefly and cause an animation artifact. To properly support background blur on those devices, a Launch image or xib must be included.

#####Setting a global alert stlyle:

// Set global stlying. This can be done sometime during app launch. You can change style options per alert as well.
URBNAlertController *alertController = [URBNAlertController sharedInstance];
alertController.alertStyler.buttonBackgroundColor = [UIColor blueColor];
alertController.alertStyler.buttonDestructionBackgroundColor = [UIColor greenColor];
alertController.alertStyler.backgroundColor = [UIColor greyColor];
alertController.alertStyler.titleFont = [UIFont fontWithName:@"" size:14.f]; 

#####Basic Active Alert (2 buttons)

URBNAlertViewController *uac = [[URBNAlertViewController alloc] initWithTitle:@"The Title of my message can be up to 2 lines long. It wraps and centers." message:@"And the message that is a bunch of text. And the message that is a bunch of text. And the message that is a bunch of text."];

// You can customize style elements per alert as well. These will override the global style just for this alert.
uac.alertStyler.blurTintColor = [[UIColor orangeColor] colorWithAlphaComponent:0.4];
uac.alertStyler.backgroundColor = [UIColor orangeColor];

[uac addAction:[URBNAlertAction actionWithTitle:@"Button 1" actionType:URBNAlertActionTypeNormal actionCompleted:^(URBNAlertAction *action) {
      // URBNAlertActionTypeNormal is triggered when the user touches the button specified by this action
}]];

[uac addAction:[URBNAlertAction actionWithTitle:@"Button 2" actionType:URBNAlertActionTypeNormal actionCompleted:^(URBNAlertAction *action) {
      // Do something
}]];
    
[uac show];

#####Active Alert with UITextField

URBNAlertViewController *uac = [[URBNAlertViewController alloc] initWithTitle:@"Input Alert" message:@"Message and message and message and going on forever and ever. Message and message and message and going on forever and ever. Message and message and message and going on forever and ever. Message and message and message and going on forever and ever. and message and message and going on forever and ever." view:nil];
    
[uac addAction:[URBNAlertAction actionWithTitle:@"Done" actionType:URBNAlertActionTypeNormal actionCompleted:^(URBNAlertAction *action) {
    NSLog(@"input: %@", uac.textField.text);
}]];
    
[uac addTextFieldWithConfigurationHandler:^(UITextField *textField) {
    textField.borderStyle = UITextBorderStyleRoundedRect;
    textField.placeholder = @"e-mail";
    textField.returnKeyType = UIReturnKeyDone;
    textField.keyboardType = UIKeyboardTypeEmailAddress;
}];
    
[uac show];

#####Basic Passive Alert

URBNAlertViewController *uac = [[URBNAlertViewController alloc] initWithTitle:@"The Title of my message can be up to 2 lines long. It wraps and centers." message:@"And the message that is a bunch of text. And the message that is a bunch of text. And the message that is a bunch of text."];
uac.alertConfig.touchOutsideViewToDismiss = YES; // Touching outside the alert view will dismiss the alert (only for passive alerts)
uac.alertConfig.duration = 2.0f; // Duration the alert appears (default calculates time based on the amount of text in the title and message. For passive alerts only)
uac.alertStyler.blurEnabled = @NO;

[uac addAction:[URBNAlertAction actionWithTitle:nil actionType:URBNAlertActionTypePassive actionCompleted:^(URBNAlertAction *action) {
    // URBNAlertActionTypePassive is triggered when the user taps on the actual alert view only for passive. Do something here, ie push a new view controller. For passive alerts only.
}]];
    
[uac show];

#####Limitations At the moment, URBNAlert only supports the following:

  • Up to 2 buttons for an active alert

Please create an issue for any additional support needed.

Requirements

  • As of v2.0.0, URBNAlert is iOS 8+. To use in iOS 7 you can lock down to v1.9.7

Installation

URBNAlert is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "URBNAlert"

Author

URBN Mobile Team, [email protected]

License

URBNAlert is available under the MIT license. See the LICENSE file for more info.

urbnalert's People

Contributors

ryang1428 avatar jgrandelli avatar codecaffeine avatar ndis1 avatar rmigneco avatar mark2b avatar dbergman avatar gemmakbarlow avatar

Watchers

James Cloos avatar kevin taniguchi 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.