Reputation: 173
I managed to set the wallpaper for macOS by:
let workspace = NSWorkspace.shared
if let screen = NSScreen.main {
try workspace.setDesktopImageURL(imgurl, for: screen, options: [:])
//imgurl is the url location of the required image
}
} catch {
print(error)
}
However, how do I set the fit style (like fill screen, fit to screen, etc)? Will it be in options?
Upvotes: 0
Views: 130
Reputation: 173
This solved it :
try workspace.setDesktopImageURL(imgurl, for: screen, options: [NSWorkspace.DesktopImageOptionKey.imageScaling : 5])
//The value of the dictionary is the desired number you want to scale the image by.
Upvotes: 1