我以编程方式向视图添加了UITextView,并向textview添加了捏手势。在捏手势中,我放大可以完美地放大。但是这里UITextView改变了它的大小。与其相反,我想更改其框架。随着我的代码textview高度变化,宽度不变。
UITextView *pinchView = (UITextView*)pinch.view;
UIFont *font = pinchView.font;
CGFloat pointSize = font.pointSize;
NSString *fontName = font.fontName;
pointSize = ((pinch.velocity > 0) ? 1 : -1) * 1 + pointSize;
if (pointSize < 13) pointSize = 13;
if (pointSize > 30) pointSize = 30;
pinchView.font = [UIFont fontWithName:fontName size:pointSize];
CGSize maximumSize = CGSizeMake(viewWidth, viewHeight);
CGSize contentSize = [pinchView sizeThatFits:maximumSize];
CGRect frame = pinchView.frame;
frame.size.height = contentSize.height;
pinchView.frame = frame;
谢谢。