public static void UpdateText(this UITextView textView, InputView inputView) { // Setting the text causes the cursor to be reset to the end of the UITextView. // So, let's set back the cursor to the last known position and calculate a new // position if needed when the text was modified by a Converter. var oldText = textView.Text ?? string.Empty; var newText = TextTransformUtilites.GetTransformedText( inputView?.Text, textView.SecureTextEntry ? TextTransform.Default : inputView.TextTransform ); // Re-calculate the cursor offset position if the text was modified by a Converter. // but if the text is being set by code, let's just move the cursor to the end. var cursorOffset = newText.Length - oldText.Length; var cursorPosition = textView.IsFirstResponder ? textView.GetCursorPosition(cursorOffset) : newText.Length; if (oldText != newText) { textView.Text = newText; } textView.SetTextRange(cursorPosition, 0); }