Scale WebView in Cocoa

后端 未结 4 982
名媛妹妹
名媛妹妹 2020-12-06 18:15

How can I scale the content of a WebView?

4条回答
  •  清歌不尽
    2020-12-06 18:37

    Or you can try the following:

    - (IBAction)takeZoom:(NSSlider *)sender {
        WebView *aWebView = [[window.contentView subviews] lastObject];
        NSView *clipView = [[[[aWebView mainFrame] frameView] documentView] superview];
        float scale = pow( 4, [sender floatValue] )/(clipView.frame.size.width/clipView.bounds.size.width);
        [clipView scaleUnitSquareToSize:NSMakeSize(scale, scale)];
        [clipView setNeedsDisplay:YES];
    }
    

提交回复
热议问题