I have a UIView
hierarchy like this UIScrollView
-> DrawingView(UIView)
-> UITextView
. When I zoom UIScrollView
, it also scaling the UITextView
causing blurred text and big font. I need the same resize frame of UITextView
but it should not get blurred and at proper font.
Showing in images what i exactly need.
Before zoom my UITextView should look like :
When I zoom, its looking like this :
This is an image where I want UITextView
should look like when I zoom/ or max zoom level.
Here is my code, Tried each 'TRY' code once but none works.
- (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));
}
deal with UITextView zoom you can do this:
//scale :zoomScale
for (UIView *subView in self.txtContent.subviews) {
subView.contentScaleFactor = scale * [UIScreen mainScreen].scale;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.