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?
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?
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
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;
}
Suppose your UITextField name is uiTextField. To set font size add the code below
_uITextField.font = UIFont.systemFont(ofSize: 10)
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
in 2021 we have properties
TextFormField(
cursorHeight: 13,
cursorColor: Colors.black)
© 2022 - 2024 — McMap. All rights reserved.