关闭

文章标题

33人阅读 评论(0) 收藏 举报
分类:
  • UITextField
    注:在.h文件中声明UITextFieldDelegage
UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(10, 74, self.view.frame.size.width - 20, 31)];
textField.borderStyle = UITextBorderStyleRoundedRect;
textField.placeholder = @"...";
textField.clearButtonMode = UITextFieldViewModeWhileEditing;
textField.secureTextEntry = YES;
textField.keyboardType = UIKeyboardTypeEmailAddress;
textField.returnKeyType = UIReturnKeyGo;
textField.textColor = [UIColor cyanColor];
textField.font = [UIFont boldSystemFontOfSize:16.0f];
textField.delegate = self;
textField.contentVerticalAlignment = UIViewContentModeCenter;
[self.view addSubview:textField];

UITextField delegate

- (BOOL)textFieldShouldEndEditing:(UITextField *)textField
- {
    - return Yes;
- }

- (void)textFieldDidEndEditing:(UITextField *)textField
- {
- }

- (BOOL)textFieldShouldReturn:(UITextField *)textField
- {
    - [textField resignFirstResponder];
    - return YES;
- }

-UITextView
在.h文件中声明UITextViewDelegate

UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(x, y, width, height)];
textView.backgroundColor = [UIColor redColor];
textView.textColor = [UIColor blackColor];
textView.keyboardType = UIKeyboardTypeEmailAddress;
textView.returnKeyType = UIReturnKeyGo;
textView.delegate = self;
[self.view addSubview:textView];

UITextView delegate

- (void)textViewDidEndEditing:(UITextView *)textView
- {
    - 
- }

- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
- {
    - if (text isEqualToString:@"n"]) {
        - [textView resignFirstResponder];
        - return NO;
    - }
    - return YES;
- }
0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:183次
    • 积分:12
    • 等级:
    • 排名:千里之外
    • 原创:0篇
    • 转载:6篇
    • 译文:0篇
    • 评论:0条
    文章分类
    文章存档