1. You have to use layers in code:
self.view.wantsLayer = true
self.view.layer?.backgroundColor = NSColor.blue.cgColor
2. The way I do it is to save positions in a JSON file
func savePositionWindows(windID: Int? = nil) {
// I save in an Array
}
To save the position and size of a specific window (I give an ID from 0 to N to each) or all
On opening I read the settings
3. To add an image in toolbar item, I did it this way
func applicationDidFinishLaunching(_ aNotification: Notification) {
// Insert code here to initialize your application
//initialize menu bar icon
statusItem = NSStatusBar.system.statusItem(withLength: CGFloat(48))
let image = NSImage(named:"MyImage")! // Select image in xcAssets
image.isTemplate = true
statusItem.button?.image = image
statusItem.button?.appearsDisabled = false
statusItem.button?.action = #selector(hideAllFromStatusMenu)
statusItem.button?.target = self
}
Note: in the forum, it is better to ask one question per thread.
Doing so, the title can be much more explicit and this helps other take profit of the thread in the future.
But for this first time, that will do.
Don't forget to close the thread if OK by marking the correct answer.