UITextView with large font size and magnifying glass

I have a UITextView wrapped inside a UIView that can be resized (increase the frame size and font) and the magnifying glass works fine with smaller text sizes

Magnifying glass working normal

But if I greatly increase the size of the text view, the magnifying glass starts to go out of its frame

enter image description here

Is it possible to simply remove the magnifying glass without affecting the choice of the cursor, or reduce the scale value inside the glass so that the content matches its frame?

+6
source share
2 answers

Well, I was able to turn off the magnifying glass without removing the cursor.

To do this, I removed the UILongPressGestureRecognizer to get rid of the magnifying glass. Then used my UIPanGestureRecognizer to track the location of the user's touch screen.

CGPoint currentPos = [panRecognizer locationInView:self]; 

and then set the cursor location

 UITextPosition *cursorPosition=[self closestPositionToPoint:CGPointMake(currentPos.x, currentPos.y)]; [self setSelectedTextRange:[self textRangeFromPosition:cursorPosition toPosition:cursorPosition]]; 
+1
source

To disable the magnifying glass, simply set the userInteractionEnabled property to NO . After that, you must manually call becomeFirstResponder when the UITextField is listening. You can use TapGestureRecognizer for this.

0
source

Source: https://habr.com/ru/post/952420/


All Articles