UIScrollView中的模糊UITextView

时间:2013-06-05 16:06:11

标签: ios uitextview blurry

我在UIScrollView中遇到模糊UITextView的问题所以我创建了一个简单的小应用程序,它只有一个ScrollView,它可以保存到一个视图上,而该视图上还有一个UITextView。下面的代码是我设置的所有代码。如果放大文字模糊。我已经看过其他关于此的帖子,建议是在UITextView上设置contentScaleFactor。但是,也不起作用。另一个建议是确保UITextField的框架不在像素之间......在我的例子中你可以看到框架在整个像素上。

所以我对如何使文本呈现清晰的想法感到茫然。

如果有任何想法,请告诉我。

谢谢,

彼得

@implementation SIAppDelegate
{
    UITextView *textView;
    float originalFontSize;
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:   (NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
   self.viewController = [[SIViewController alloc] initWithNibName:@"SIViewController"    bundle:nil];
   self.window.rootViewController = self.viewController;

   //Setting up the scroll view
   UIScrollView *scrollView = (UIScrollView *)self.viewController.view;
   scrollView.delegate = self;

   scrollView.maximumZoomScale = 5;
   scrollView.minimumZoomScale = 1;

   //Setting up the content view
   UIView *view = [[UIView alloc] initWithFrame:scrollView.frame];    
   view.backgroundColor = [UIColor blueColor];

   textView = [[UITextView alloc] initWithFrame:CGRectIntegral(CGRectMake(200, 200, 200, 200))];
   textView.text = @"Hello, World";

   [view addSubview:textView];
   [scrollView addSubview:view];

   scrollView.contentSize = CGSizeMake(2000, 2000);


   [self.window makeKeyAndVisible];
   return YES;
}



-(UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView 
{
    return scrollView.subviews[0];
}

-(void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(float)scale
{
 [scrollView.subviews[0] setContentScaleFactor:scale];

textView.contentScaleFactor = scale;


}

@end

1 个答案:

答案 0 :(得分:0)

试着看看这篇文章: Stackoverflow

看起来缩放因子是正确的方法,但只使用scrollview委托中的默认缩放不足以获得清晰的文本。