Reputation: 179
I have UITextField with too long cursor(the cursor for "123123" in the following image)
How to make the height of the cursor same with the height of text?
Upvotes: 7
Views: 7116
Reputation: 12345
in 2021 we have properties
TextFormField(
cursorHeight: 13,
cursorColor: Colors.black)
Upvotes: -1
Reputation: 4667
I accidentally stumbled across this question and even though it is a little old I feel compelled to answer it since the accepted answer actually isn't correct.
You can indeed change the height (or width) of the cursor. Just subclass the UITextField
and override this method:
- (CGRect)caretRectForPosition:(UITextPosition *)position {
CGRect rect = [super caretRectForPosition:position];
rect.size.height = 42;
return rect;
}
Upvotes: 17
Reputation: 82756
we can't change the cursor height , but we can do some trick , select your textfield and change your textfield border style as UITextBorderStyleNone
you get the out put as
there after increase the font size of your textfield whatever you want , then you get the output as
Upvotes: 0
Reputation: 774
Suppose your UITextField name is uiTextField. To set font size add the code below
_uITextField.font = UIFont.systemFont(ofSize: 10)
Upvotes: 0