Giter Club home page Giter Club logo

mbalertview's Introduction

MBAlertView

MBAlertView is a fun and simple block-based alert and HUD library for iOS, as seen in Notestand.

Features

  • Nested alerts and HUDs
  • Block based
  • Images
  • Nice animations
  • Doesn't use any PNG files. Everything is drawn with code.

Extended Features in this fork

// create an alert view with 'title' and 'message', using default colors, layout and no buttons
    MBAlertView *alert = [MBAlertView alertWithTitle:title message:message];

// set the title font
    alert.titleFont = [UIFont fontWithName:@"MyCustomFont-Regular"  size:22];

// set custom background image for the alert view.
    alert.backgroundImage = [UIImage imageNamed:@"Popup_Box_Background"];

// set custom body view for the alert body part. This allows e.g. to have a separate body-part background image or more complex view heirarchy for the body part only. Default is nil, in which case the alert will use the bodyText in the body area.
    alert.customBodyView = [NSBundle mainBundle] loadNibNamed:@"AlertBodyView" owner:nil options:nil];

// By default the alert will mask the underlying view with semi-transparent black mask.
	alert.addsMask = NO; // default is YES
	
// set the size for the alert view, in this case match the background image size
	alert.size = alert.backgroundImage.size;

/* By default, the message of the alert is centered in the alert's bounds. 
   However, our Popup_Box_Background contains drop shadow, 
   which offsets the actual center from the visible center of the popup rect (without the shadow).
   offset the content upward a bit by setting contentEdgeInsets 
*/
    alert.contentEdgeInsets = UIEdgeInsetsMake(0, 0, 14, 0);

// add custom cancel button
   UIImage *image = [UIImage imageNamed:@"Cancel_Button_Background"];
   UIButton *button = [[UIButton alloc] initWithFrame:(CGRect){CGPointZero, image.size}];
   [button setBackgroundImage:image forState:UIControlStateNormal];
   [button.titleLabel setFont:[UIFont fontWithName:@"MyCustomFont-Regular" size:16]];
   [button setTitle:cancelTitle forState:UIControlStateNormal];
    
   [alert addCustomButton:button block:^{
   		// any button automatically dismisses the alert view
   		// this block is useful for additional handler code after the alert is dismissed. 
   }]; 
 
   [alert addToDisplayQueue];

Usage

There are two factory methods to get you started:

Alerts

// Create an alert with a standard canel button
+(MBAlertView*)alertWithTitle:(NSString*)title message:(NSString*)body cancelTitle:(NSString*)cancelTitle cancelBlock:(id)cancelBlock;

// Create an alert with no buttons (you can add buttons using addButtonWithText: or addCustomButton:)
+(MBAlertView*)alertWithTitle:(NSString*)title message:(NSString*)body;
[alert addToDisplayQueue];

HUDs

[MBHUDView hudWithBody:@"Wait." type:MBAlertViewHUDTypeActivityIndicator hidesAfter:4.0 show:YES];

You can see more in the easy to follow demo.

License

MBAlertView is available under the MIT license.

mbalertview's People

Contributors

rubnov avatar

Stargazers

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