• 周三. 4 月 22nd, 2026

物嫩软件资讯网

软件资讯来物嫩

macOS开发,如何设置动态桌面壁纸(动态壁纸酷)

admin@wunen

4 月 2, 2025

1.首先要先建立一个全屏的窗口

//获取窗口控制器
NSStoryboard *storyboard = [NSStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];
WallpaperWindowController *wwc = [storyboard instantiateControllerWithIdentifier:@"AboutWindowController"];

//获取当前所有屏幕,你可能有多个显示器
NSArray(NSScreen * ) * screens = [NSScreen screens];

//设置为全屏窗口
CGRect rect = CGRectMake(screen.frame.origin.x, screen.frame.origin.y, screen.frame.size.width, screen.frame.size.height);
[self.window setFrame:rect display:YES animate:NO];
[self.window makeKeyAndOrderFront:nil];

2.设置窗口层级

//设置与桌面同级别
[self.window setLevel:kCGDesktopWindowLevel];

3.设置跟随工作空间显示

[self.window setCollectionBehavior:(NSWindowCollectionBehaviorCanJoinAllSpaces | NSWindowCollectionBehaviorStationary | NSWindowCollectionBehaviorIgnoresCycle)];

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注