【问题标题】:NSView enterFullScreenWithOptions: scaling the NSViewNSView enterFullScreenWithOptions:缩放 NSView
【发布时间】:2011-01-23 03:46:23
【问题描述】:

所以,参考:Kiosk Applications - OS X programming - Multiple monitors

我有一个 800x600 的 NSView,当我使用 NSView 的 enterFullScreenModeWithOptions 进入全屏模式时,我需要按比例缩放它。

现在,UI 元素在它们最初定义的位置是静止的,并且视图处于全屏模式。最重要的是,我的视图有一个背景图像,它也占据了显示器左上角的 800x600 正方形。那么如何在全屏模式下按比例缩放视图中的所有内容以适应屏幕?

再次感谢,
光辉

【问题讨论】:

    标签: cocoa macos


    【解决方案1】:

    我实现了一个查看器,它继承了 NSView 的形式。在我的图像被绘制之前,我会调整[image setSize:size] 的大小以使我的图像适合全屏。

    if([myviewer isInFullScreenMode]){
        int width = [[NSScreen mainScreen] frame].size.width;
        int height = [[NSScreen mainScreen] frame].size.height;
    
        NSSize size;
    
        size.width = width;
        size.height = height;
    
        [image setScalesWhenResized:YES];
        [image setSize:size];
    }
    

    希望,这可以帮助任何人。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-05-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-10-31
      • 1970-01-01
      • 2019-08-09
      • 1970-01-01
      相关资源
      最近更新 更多