Latest 1.0.1
Homepage https://github.com/dai-jing/KBAlertController
License MIT
Platforms ios 8.0, requires ARC
Authors

License

A user custom UIAlertController class with a simplified, chainable and expressive syntax.

Introduction

You can custom your own alert and actionsheet view’s style and action’s style. It uses UIAlertController similar API methods which you can simply use it.

demo
demo

Installation

The preferred way of installation is via CocoaPods. Just add

pod 'KBAlertController'

Usage

you can customize styles with a simplified, chainable and expressive syntax.

// Alert
KBAlertController *alertController = [KBAlertController alertControllerWithTitle:@"Alert" message:@"Are you sure to cancel?" style:^(KBAlertControllerStyle *style) {
    style.type = KBAlertControllerTypeAlert;
}];

KBAlertAction *doneAction = [KBAlertAction actionWithTitle:@"Done"
                                                     style:^(KBAlertActionStyle *style) {
                                                         style.font = [UIFont systemFontOfSize:15.f];
                                                     } handler:^{
                                                         NSLog(@"done button clicked");
                                                     }];
KBAlertAction *confirmAction = [KBAlertAction actionWithTitle:@"Confirm"
                                                        style:^(KBAlertActionStyle *style) {
                                                            style.type = KBAlertActionTypeDestructive;
                                                        } handler:^{
                                                            NSLog(@"confirm button clicked");
                                                        }];
[alertController addActions:@[doneAction, confirmAction]];

[self presentViewController:alertController animated:YES completion:nil];
// ActionSheet
KBAlertController *alertController = [KBAlertController alertControllerWithTitle:@"Alert" message:@"Are you sure to cancel?" style:^(KBAlertControllerStyle *style) {
    style.type = KBAlertControllerTypeActionSheet;
}];

KBAlertAction *doneAction = [KBAlertAction actionWithTitle:@"Done"
                                                     style:^(KBAlertActionStyle *style) {
                                                         style.font = [UIFont systemFontOfSize:15.f];
                                                     } handler:^{
                                                         NSLog(@"done button clicked");
                                                     }];
KBAlertAction *confirmAction = [KBAlertAction actionWithTitle:@"Confirm"
                                                        style:^(KBAlertActionStyle *style) {
                                                            style.type = KBAlertActionTypeDestructive;
                                                        } handler:^{
                                                            NSLog(@"confirm button clicked");
                                                        }];
[alertController addActions:@[doneAction, confirmAction]];

[self presentViewController:alertController animated:YES completion:nil];

Latest podspec

{
    "name": "KBAlertController",
    "version": "1.0.1",
    "summary": "Custom UIAlertController",
    "homepage": "https://github.com/dai-jing/KBAlertController",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Jing Dai": "[email protected]"
    },
    "platforms": {
        "ios": "8.0"
    },
    "requires_arc": true,
    "source": {
        "git": "https://github.com/dai-jing/KBAlertController.git",
        "branch": "master",
        "tag": "1.0.1"
    },
    "source_files": "*.{h,m}",
    "public_header_files": "*.h"
}

Pin It on Pinterest

Share This