custom UITextField with image as a background blinking cursor issue

后端 未结 3 468

I have a custom UITextField with a UIImage as a background. Now when I type in a text into this UITextField and the cursor is blinking I get this:

3条回答
  •  南方客
    南方客 (楼主)
    2021-01-24 15:18

    I just tried it. It does not have the cursor highlighted like that.

    set

    textField.backgroundColor = [UIColor brownColor] // or your color
    

    and

    textField.textColor = [UIColor whiteColor];
    

    For adding the textField into the UIView ;

    //Do this where you create the UIView* view
    
    
        UITextField *textField = [[UITextField alloc]initWithFrame:CGRectMake(110, 10, 185, 30)];
        textField.clearsOnBeginEditing = NO;
        textField.textAlignment = UITextAlignmentRight;
        textField.returnKeyType = UIReturnKeyDone;
        textField.textColor = [UIColor blackColor]; // or any other color
    
        textField.font = [UIFont systemFontOfSize:15];
        textField.delegate = self;
    
    
        [view addSubview:textField];
    

提交回复
热议问题