这个问题是similar to this one,但希望它会拿起更多的兴趣,因为我尝试了一些东西。缩放UITextView和内容大小
我想在UITextView中做标准的平底锅滚动。我的委托实现UITextViewDelegate
和实现此方法
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView {
return self;
}
[这实际上可能是错的,但在返回[[self subviews] objectAtIndex:0]
没有改变任何东西(奇怪)。
所以捏的东西的作品,但是当有一个缩放,UITextView实例失去了所有的想法,让我平移内容的正确。我试图通过包括这种方法来解决这个问题
- (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(float)scale {
CGSize size = self.contentSize;
size.width *= scale;
size.height *= scale;
self.contentSize = size;
}
但是所有这些猜测并没有让我走得很远(并不奇怪)。
编辑︰我做了这样的事情,除了它吹了一下后,它不完全是我想要的。这是一个UIPincheGestureRecognizer
的action
方法:
- (void) doSomething:(id)sender {
CGFloat factor = [(UIPinchGestureRecognizer *)sender scale];
float size = 12 * factor;
if (size > 6 && size < 40) {
self.font = [[UIFont fontWithName:self.font.fontName size:12 * factor] autorelease];
}
}
看起来不错+1,我会检查它在某些时候,接受这个答案,如果它是对。谢谢! – 2012-12-11 17:31:41