You gan get all the screens from this code:
let screens = NSScreen.screens
And set wallpaper By This code
let newWallpaperURL = URL(/* ... */)
for i in screens {
try! NSWorkspace.shared().setDesktopImageURL(newWallpaperURL, for: i, options: [:])
}
More Related Contents:
- How can I deal with @objc inference deprecation with #selector() in Swift 4?
- Trying to Understand Asynchronous Operation Subclass
- SwiftUI: How to pop to Root view
- UITableview with more than One Custom Cells with Swift
- Deinit method is never called – Swift playground
- What are the new “for”, “at”, “in” keywords in Swift3 function declarations?
- Send data from TableView to DetailView Swift
- How do I declare an array of weak references in Swift?
- Getting the decimal part of a double in Swift
- Swift: how to use PREPROCESSOR Flags (like `#if DEBUG`) to implement API keys?
- Using a Type Variable in a Generic
- Convert String to URL (Why is resulting variable nil)
- What sorting algorithm does Swift implement for its standard library?
- Swift – IBOutletCollection equivalent
- dispatch_once after the Swift 3 GCD API changes
- SwiftUI: Forcing an Update
- How to use openURL for making a phone call in Swift?
- How can I get a real IP address from DNS query in Swift?
- Get class name of object as string in Swift
- Getting “file not found” in Bridging Header when importing Objective-C frameworks into Swift project
- Why is ‘nil’ not compatible with ‘UnsafePointer’ in Swift 3?
- AlamoFire asynchronous completionHandler for JSON request
- Setting the TimelineProvider refresh interval for Widget
- How do I find the beginning of the week from an NSDate?
- Twitter Call back URL
- How to get user home directory path (Users/”user name”) without knowing the username in Swift3
- Swift find all occurrences of a substring
- Swift compiler segmentation fault when building
- SwiftUI add inverted mask
- In Swift 4, how do I remove a block-based KVO observer?