我正在尝试为我的iOS应用程序创建动态UITextViewController。所以从我的ApplicationViewController我试图获取TextView。
Textview正常运行但我的UITextView的输入光标下降了。如何从顶部获取蓝色输入光标?
+(UITextField *)prepareUITextView
{
UITextView *uiTextView= [[UITextView alloc] initWithFrame:CGRectMake(
10, 80, 300, 100)];
uiTextView.layer.borderWidth = 1.0;
uiTextView.layer.cornerRadius = 8;
uiTextView.font = [UIFont systemFontOfSize:15];
uiTextView.autocorrectionType = UITextAutocorrectionTypeNo;
uiTextView.keyboardType = UIKeyboardTypeDefault;
uiTextView.returnKeyType = UIReturnKeyDone;
[uiTextView becomeFirstResponder];
uiTextView.selectedRange = NSMakeRange(0, 0);
return uiTextView;
}
[self.view addSubview:[TextViewController prepareUITextView]];
答案 0 :(得分:2)
试试此代码
uiTextView.contentInset = UIEdgeInsetsMake(-7.0,0.0,0,0.0);
按照您想要的方式调整Top值。这将解决您的问题。