#import <UIKit/UIKit.h>
@interface customTextField : UITextField
@end
#import "customTextField.h"
@implementation customTextField
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
UIToolbar * topKeyboardView = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 0, self.frame.size.width, 40)];
[topKeyboardView setBarStyle:UIBarStyleDefault];
UIBarButtonItem * btnSpace = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
UIBarButtonItem * doneButton = [[UIBarButtonItem alloc]initWithTitle:NSLocalizedStringFromTable(@"Done",nil,nil) style:UIBarButtonItemStyleDone target:self action:@selector(dismissKeyBoard)];
NSArray * buttonsArray = [NSArray arrayWithObjects:btnSpace,doneButton,nil];
[topKeyboardView setItems:buttonsArray];
[self setInputAccessoryView:topKeyboardView];
}
return self;
}
-(void)dismissKeyBoard
{
[self resignFirstResponder];
}
IOS 键盘 隐藏
最新推荐文章于 2019-05-27 18:28:09 发布