Created
August 29, 2012 18:33
-
-
Save tpthn/3516777 to your computer and use it in GitHub Desktop.
iOS - dismiss keyboard when touch on background
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//--Touch to dismiss keyboard | |
UIButton *dismissKeyboardButtonBg = [UIButton buttonWithType:UIButtonTypeCustom]; | |
dismissKeyboardButtonBg.backgroundColor = [UIColor clearColor]; | |
[dismissKeyboardButtonBg addTarget:self action:@selector(dismissKeyboard:) forControlEvents:UIControlEventTouchUpInside]; | |
[dismissKeyboardButtonBg setFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height)]; | |
[dismissKeyboardButtonBg setAutoresizingMask:UIViewAutoresizingFlexibleWidth]; | |
[self.view addSubview:dismissKeyboardButtonBg]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment