//键盘追加完成按钮
    UIToolbar * topView = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 0, 320, 30)];
    [topView setBarStyle:UIBarStyleDefault];
    UIBarButtonItem * btnSpace = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    btn.frame = CGRectMake(2, 10, 50, 25);
    [btn addTarget:self action:@selector(dismissKeyBoard) forControlEvents:UIControlEventTouchUpInside];
    [btn setTitle:@"完成"forState:UIControlStateNormal];
    
    [btn setTitleColor:[UIColor colorWithRed:31.0/255.0 green:112.0/255.0 blue:175.0/255.0 alpha:1.0] forState:UIControlStateNormal];
    btn.titleLabel.textColor=[UIColor redColor];
    UIBarButtonItem *doneBtn = [[UIBarButtonItem alloc]initWithCustomView:btn];
    NSArray * buttonsArray = [NSArray arrayWithObjects:btnSpace,doneBtn,nil];
    [topView setItems:buttonsArray];
    [_texTest setInputAccessoryView:topView];
}
原文:http://www.cnblogs.com/lanmaokomi/p/7552647.html