I try to vertically center my text cursor in a UITextView.
// creating the inputText
[inputTextView removeFromSuperview];
inputTextView = [[UITextView alloc]initWithFrame:CGRectMake(CGRectGetMaxX(searchIconsButton.frame) + 3 , 0, buttomView.frame.size.width * 0.78 , buttomView.frame.size.height *0.80)];
inputTextView.layer.borderColor = [UIColor lightGrayColor].CGColor;
inputTextView.layer.borderWidth = 0.6;
inputTextView.center = CGPointMake(inputTextView.center.x, buttomView.frame.size.height / 2);
inputTextView.autocorrectionType = UITextAutocorrectionTypeNo;
[inputTextView.layer setCornerRadius:6];
[inputTextView setTintColor:[UIColor blackColor]]; // set the cursor color to black
inputTextView.textAlignment = UIControlContentVerticalAlignmentCenter;
I try in last line to do UIControlContentVerticalAlignmentCenter but it still do not work .
You can see that the cursor hides into the Textview.
There is a way to solve it?
Use the textContainerInset
property of UITextView
, available iOS 7.0 and later.
inputTextView.textContainerInset = UIEdgeInsetsMake(-2,0,0,0); // Move cursor up 2
Play around with the values until it fits your needs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With