UIButton类型为 UIButtonTypeCustom, 添加一个方法
[button addTarget:self action:@selector(hideKeyboard) forControlEvents:UIControlEventTouchUpInside];
方法一
-(void)hideKeyboard
{
[myTextfield resignFirstResponder];
}
方法二
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[_userNumber resignFirstResponder];
[_userPassword resignFirstResponder];
}
本文详细介绍了如何在iOS应用中使用UIButton实现自定义样式,并通过添加方法来触发键盘隐藏事件,包括直接调用方法及响应触摸事件两种方式。
1866

被折叠的 条评论
为什么被折叠?



