MKInputBoxView is a class to replace UIAlertView. It is basically an Objective-C port of BMInputBox, which is written in Swift.
Built in Objective-C for iOS 8.0 and above. ARC-enabled. For both iPhone and iPad.
CocoaPods is the recommended way to add MKInputBoxView to your project. Just add
pod 'MKInputBoxView'
and run
pod install
. It will install the most recent version of MKInputBoxView.
If you would like to use the latest code of MKInputBoxView use:
pod 'MKInputBoxView', :head
Alternatively, just add MKInputBoxView.h
and MKInputBoxView.m
to your project.
MKInputBoxView *inputBoxView = [MKInputBoxView boxOfType:NumberInput];
[inputBoxView show];
Available styles:
PlainTextInput
- Simple text fieldNumberInput
- Text field accepting numbers only - numeric keyboardPhoneNumberInput
- Text field accepting numbers only - phone keyboardEmailInput
- Text field accepting email addresses - email keyboardSecureTextInput
- Secure text field for passwordsLoginAndPasswordInput
- Two text fields for user and password entry
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;
};
inputBoxView.onSubmit = ^(NSString *value1, NSString *value2) {
NSLog(@"user: %@", value1);
NSLog(@"pass: %@", value2);
if ([value1 isValid] && [value2 isValid]){
return YES; // YES to hide the inputBoxView
} else {
return NO; // NO will keep the inputBoxView open
}
};
inputBoxView.onCancel = ^{
NSLog(@"Cancel!");
};