现在的位置: 首页 > 综合 > 正文

mac应用实现全屏的体验

2014年01月01日 ⁄ 综合 ⁄ 共 688字 ⁄ 字号 评论关闭

这里是苹果官方关于实现全屏体验的文档:http://developer.apple.com/library/mac/#documentation/General/Conceptual/MOSXAppProgrammingGuide/FullScreenApp/FullScreenApp.html

1. 实现全屏体验,可以自定义NSWindow,重新实现期初始化方法。

    - (id)initWithContentRect:(NSRect)contentRect 
                    styleMask:(NSUInteger)styleMask 
                      backing:(NSBackingStoreType)bufferingType 
                        defer:(BOOL)flag { 
        if ([SystemVersion compare:@"10.7.0"] >= 0) {
            self = [super initWithContentRect: contentRect styleMask: NSBorderlessWindowMask backing: NSBackingStoreBuffered defer: NO];
        } 
        else {
            self = [super initWithContentRect: contentRect styleMask: NSBorderlessWindowMask backing: NSBackingStoreBuffered defer: NO];
        }
        
        return self;
    }

2. 设置窗口支持全屏体验

    [window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];

抱歉!评论已关闭.