Just like UITextField, but there are some differences listed below.
Last active
August 29, 2015 14:02
-
-
Save JeOam/52bfa9d6ecbc00c81bb1 to your computer and use it in GitHub Desktop.
UITextView 模板
UITextView dissmissKeyBoard:
// 在输入框加一个 Done 按钮退出键盘
UIToolbar *topView = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 320, 30)];
// 这里缺少 Button1,Button2 的话,doneButton 按钮会被放到 toolbar 的左边
UIBarButtonItem *Button1 = [[UIBarButtonItem alloc]initWithTitle:@"" style:UIBarButtonItemStyleBordered target:self action:nil];
UIBarButtonItem *Button2 = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithTitle:@"Done" style:UIBarButtonItemStyleDone target:self action:@selector(dismissKeyBoard)];
[topView setItems:@[Button1,Button2,doneButton]];
[self.textView setInputAccessoryView:topView];
-(void)dismissKeyBoard{
[self.textView resignFirstResponder];
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Style UITextview to like Rounded Rect text field:
There is no implicit style that you have to choose, it involves writing a bit of code using the QuartzCore framework:
via clock