我有一个UIView
层次结构,如UIScrollView
- > DrawingView(UIView)
- > UITextView
。当我缩放UIScrollView
时,它还会缩放UITextView
,从而导致模糊文字和大字体。我需要UITextView
相同的调整大小框架,但它不应该模糊和正确的字体。
在图片中显示我确切需要的内容。
在缩放之前,我的UITextView应如下所示:
当我缩放时,它看起来像这样:
当我缩放/或缩放缩放级别时,这是我想要UITextView
的样子。
这是我的代码,尝试了一次'TRY'代码,但没有一个。
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView {
return self.drawingView;
}
- (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(float)scale
{
// TRY 1
self.textView.bounds = CGRectMake(0, 0, self.textView.frame.size.width*scale, self.textView.frame.size.height*scale);
// TRY 2
scale *= [[[scrollView window] screen] scale];
self.textView.contentScaleFactor = scale;
// TRY 3
CGRect frame = self.textView.frame;
frame.size.width = frame.size.width * scale;
frame.size.height = frame.size.height * scale;
self.textView.frame = frame;
self.textView.contentScaleFactor = 1.0f;
// TRY 4
self.textView.transform = CGAffineTransformScale(CGAffineTransformIdentity, scale, scale);
// TRY 5
scaleTracker *= scale;
[self.drawingView setTransform:CGAffineTransformIdentity];
self.drawingView.frame = CGRectMake((int)self.drawingView.frame.origin.x,
(int)self.drawingView.frame.origin.y,
(int)(self.drawingView.frame.size.width * scaleTracker),
(int)(self.drawingView.frame.size.height * scaleTracker));
NSLog(@"TextView Frame : %@",NSStringFromCGRect(self.textView.frame));
NSLog(@"DrawingView Frame : %@",NSStringFromCGRect(self.drawingView.frame));
}
答案 0 :(得分:0)
通过UITextView缩放进行交易,您可以执行以下操作:
//scale :zoomScale
for (UIView *subView in self.txtContent.subviews) {
subView.contentScaleFactor = scale * [UIScreen mainScreen].scale;
}