Масштабировать размер шрифта UITextView на UIView
У меня есть UITextView
добавил на мой UIView
, Это просто для отображения строки. Когда я добавлю UIPinchGestureRecognizer
к моему UIView
:
UIPinchGestureRecognizer * pinchGR = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(handlePinch:)];
pinchGR.delegate = self;
[self addGestureRecognizer:pinchGR];
Затем я обрабатываю действие для моего UIView и масштабирую размер шрифта в 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;
}
И это мой результат, мой UITextView
показать очень плохо (непрозрачно)
Как я могу сделать это как Snapchat?
Пожалуйста, дайте мне несколько идей.
1 ответ
-(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];
попробуй это!!!...