39 lines
1.2 KiB
Objective-C
39 lines
1.2 KiB
Objective-C
//
|
|
// UITextField+KeyBordDoneView.m
|
|
// Ifish
|
|
//
|
|
// Created by imac on 17/2/15.
|
|
// Copyright © 2017年 lianlian. All rights reserved.
|
|
//
|
|
|
|
#import "UITextField+KeyBordDoneView.h"
|
|
|
|
@implementation UITextField (KeyBordDoneView)
|
|
-(void)keybordViewAddDoneView
|
|
{
|
|
UIToolbar * topView = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 0, 320, 30)];
|
|
[topView setBarStyle:UIBarStyleBlackTranslucent];
|
|
|
|
UIBarButtonItem * btnSpace = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
|
|
|
|
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
btn.frame = CGRectMake(2, 5, 50, 25);
|
|
[btn addTarget:self action:@selector(dismissKeyBoard) forControlEvents:UIControlEventTouchUpInside];
|
|
// [btn setImage:[UIImage imageNamed:@"shouqi"] forState:UIControlStateNormal];
|
|
[btn setTitle:@"完成" forState:UIControlStateNormal];
|
|
UIBarButtonItem *doneBtn = [[UIBarButtonItem alloc]initWithCustomView:btn];
|
|
NSArray * buttonsArray = [NSArray arrayWithObjects:btnSpace,doneBtn,nil];
|
|
[topView setItems:buttonsArray];
|
|
[self setInputAccessoryView:topView];
|
|
|
|
}
|
|
|
|
-(void)dismissKeyBoard
|
|
{
|
|
|
|
[self resignFirstResponder];
|
|
|
|
}
|
|
|
|
@end
|