/GHPopupEditView

Primary LanguageObjective-CGNU General Public License v3.0GPL-3.0

GHPopupEditView

Build Pod Version Platform Device License

A popup view for editing information.

Preview

  • GIF
  • Preview
  • Preview

Usage

GHPopupEditView *popupView = [[GHPopupEditView alloc] init];
[popupView setTitle:@"edit nickname"];
[popupView setPlaceholderString:@"Please enter a nickname"];
[popupView setKeyboardType:UIKeyboardTypeDefault];
[popupView setOKButtonThemeColor:[UIColor orangeColor]];
[popupView setShouldChangeHandler:^(UITextField *textField, NSRange range, NSString *replacementString) {
    if (range.length == 0) { // add
        NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", @"[\\w_]+"];
        return [predicate evaluateWithObject:replacementString];
    }
    return YES;
}];
[popupView setVerifyHandler:^(NSString *text) {
    NSString *nickname = [text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
    if (nickname.length == 0) {
        return @"Nickname can not be empty.";
    }
    return @"";
}];
[popupView setCompletionHandler:^(NSString *text) {
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:[NSString stringWithFormat:@"hello %@.", text] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
    [alert show];
}];
[popupView show];

Requirements

  • iOS 7.0+
  • Xcode 8.0+

Installation

Add manually:

  • Drag GHPopupEditView folder to your project.
  • Import header file: #import "GHPopupEditView.h"

Installation with CocoaPods

Podfile

platform :ios, '7.0'

target 'TargetName' do
    pod 'GHPopupEditView', '~> 1.0.0'
end

Then, run the following command:

$ pod install

License

GHPopupEditView is licensed under the GPL License - see the LICENSE file for details