一个用于编辑信息的弹出视图。
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];
手动添加
GHPopupEditView
文件夹拖到你的项目中。#import "GHPopupEditView.h"
GHPopupEditView
适用于 GPL 许可证 - 详细信息请查看 LICENSE 文件