1

I have a UITextView added on my UIView. It is just to display a string. When I add UIPinchGestureRecognizer to my UIView:

UIPinchGestureRecognizer * pinchGR = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(handlePinch:)];
pinchGR.delegate = self;
[self addGestureRecognizer:pinchGR];

Then i handle action for my UIView and scale font size in UITextView

- (void)handlePinch:(UIPinchGestureRecognizer *)recognizer {
recognizer.view.transform = CGAffineTransformScale(recognizer.view.transform, recognizer.scale, recognizer.scale);
CGFloat currentSize = _textView.font.pointSize;
CGFloat toSize = currentSize * recognizer.scale ;
[_textView setFont:[UIFont systemFontOfSize:toSize]];
recognizer.scale = 1;
}

And this is my result, my UITextView show very bad (opaque)

myIMG

How can i do it like Snapchat ?

snapchatIMG

Please give me some ideas.

iAnurag
  • 9,286
  • 3
  • 31
  • 48
Lê Trinh
  • 327
  • 3
  • 11

1 Answers1

0
-(void)handlePinchWithGestureRecognizer:(UIPinchGestureRecognizer *)pinchGestureRecognizerher //UIFont *font = txtqutoes.font;
CGFloat pointSize = font.pointSize;
NSString *fontName = font.fontName;
UIFont *font = textview.font;

pointSize = ((pinchGestureRecognizer.velocity > 0) ? 1 : -1) * 1 + pointSize;

if (pointSize < 13) pointSize = 13;
if (pointSize > 80) pointSize = 80;

textview.font = [UIFont fontWithName:fontName size:pointSize];

try this !!!...