我正在尝试为使用WebView显示一些HTML代码的Mac制作程序。我需要缩小网页内容以横向完全适合屏幕(我不关心垂直)。为此,我实现了方法:
-(void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)webFrame{
if([webFrame isEqual:[self.webView mainFrame]]){
//scale page to correct size
NSRect webFrameRect = [[[webFrame frameView] documentView] frame];
float scale = ([[[[self.webView mainFrame] frameView] documentView] superview].frame.size.width) / webFrameRect.size.width;
[[[[[self.webView mainFrame] frameView] documentView] superview] scaleUnitSquareToSize:NSMakeSize(scale, scale)];
[[[[[self.webView mainFrame] frameView] documentView] superview] setNeedsDisplay:YES];
self.webView.alphaValue = 1;
}//end if
}//end method
这种缩放方法工作正常,但问题是现在加载的任何文本看起来都很模糊。有没有办法在缩放视图后使文本更清晰?
谢谢!