如何放大和缩小iPhone中的文本视图?

时间:2012-11-13 05:17:49

标签: iphone objective-c ios

  

可能重复:
  UITextview with zooming?

UITextview中是否有放大和缩小选项。如果我点击文本视图我想要缩放文本。

帮帮我怎么做?

感谢。

1 个答案:

答案 0 :(得分:1)

当您可以在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];
}