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:
What about creating a UIImageView
with your image in it, and then embedding a borderless UITextField
inside your image view? The text field will still be editable, but shouldn't interfere with the imageview behind it.
Have you tried setting textField.backgroundColor = [UIColor clearColor]
?
You can use a UIImageView for the image and then add a UITextField as a subview with clear background. Just create UIImageView *imageView
and UITextField *textField
, either programmatically or in the IB. If you go programmatically, use [imageView addSubview:textField];
and set the frame as you like. In the IB, just drop the textField
onto the imageView
and align it as you like.
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];