MKInputBoxView 0.9.3

MKInputBoxView 0.9.3

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Mar 2015

Maintained by Martin Kautz.




MKInputBoxView is a class to replace UIAlertView. It is basically an Objective-C port of BMInputBox, which is written in Swift.

alt tag alt tag alt tag

Requirements

Built in Objective-C for iOS 8.0 and above. ARC-enabled. For both iPhone and iPad.

Adding MKInputBoxView To Your Project

Usage

Creating an input box

MKInputBoxView *inputBoxView = [MKInputBoxView boxOfType:NumberInput];
[inputBoxView show];

Available styles:

  • PlainTextInput - Simple text field
  • NumberInput - Text field accepting numbers only - numeric keyboard
  • PhoneNumberInput - Text field accepting numbers only - phone keyboard
  • EmailInput - Text field accepting email addresses - email keyboard
  • SecureTextInput - Secure text field for passwords
  • LoginAndPasswordInput - Two text fields for user and password entry

Customising the box

Changing the blur effect (UIBlurEffectStyle: ExtraLight, Light, Dark).

[inputBoxView setBlurEffectStyle:UIBlurEffectStyleDark];

Set title and message.

[inputBoxView setTitle:@"Who are you?"];
[inputBoxView setMessage:@"Please enter your username and password to get access to the system."];

Set text of the buttons

[inputBoxView setSubmitButtonText:@"OK"];
[inputBoxView setCancelButtonText:@"Cancel"];

Decimals for the NumberInput type. Default is 0. If set, the user input will be converted to Double with 2 decimals.

[inputBoxView setNumberOfDecimals:2];

Easy way to manipulate the textField's properties.

inputBoxView.customise = ^(UITextField *textField) {
    textField.placeholder = @"Your eMail address";
    if (textField.secureTextEntry) {
        textField.placeholder = @"Your password";
    }
    textField.textColor = [UIColor whiteColor];
    textField.layer.cornerRadius = 4.0f;
    return textField;
};

Closures for submission and cancellation

inputBoxView.onSubmit = ^(NSString *value1, NSString *value2) {
    NSLog(@"user: %@", value1);
    NSLog(@"pass: %@", value2);
};
inputBoxView.onCancel = ^{
    NSLog(@"Cancel!");
};