可能重复:
带有缩放的 UITextview?
UITextview 中是否有任何放大和缩小选项。如果我点击文本视图,我希望文本放大。
帮助我如何做到这一点?
谢谢。
当您可以增加 UITextView 委托的字体大小时,缩放 UITextView 是没有意义的。
UITextView *textView = [UITextView alloc] initWithFrame:CGRectMake(0, 0, 320, 200)];
UIPinchGestureRecognizer *gestureRecognizer = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(changeFontSize:)];
[textView addGestureRecognizer:gestureRecognizer];
- (void)changeFontSize:(UIPinchGestureRecognizer *)gestureRecognizer {
UITextView *textView = (UITextView *)gestureRecognizer.view;
float yourFontSize = gestureRecognizer.scale * FONT_SIZE;
textView.font = [UIFont systemFontOfSize:yourFontSize];
}