Я пытаюсь создать приложение macOS с элементом строки состояния, в котором используется изображение PDF, а не PNG, однако при использовании этого изображения оно масштабируется и весь элемент состояния становится черным. Я не могу найти способ масштабировать изображение так, чтобы оно соответствовало остальным элементам строки состояния ma c.
Icon
- Font Awesome
- (я не могу прикрепить pdf, поэтому вам нужно будет преобразовать его вручную)
Assets.xcassets
![image of scode showing the pdf icon of a globe](https://i.stack.imgur.com/70ILa.png)
AppDelegate.swift
import Cocoa
@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {
let statusItem = NSStatusBar.system.statusItem(withLength:NSStatusItem.squareLength)
func applicationDidFinishLaunching(_ aNotification: Notification) {
// Insert code here to initialize your application
if let button = statusItem.button {
button.image = NSImage(named:NSImage.Name("status-logo"))
button.action = #selector(printQuote(_:))
}
}
@objc func printQuote(_ sender: Any?) {
let quoteText = "Never put off until tomorrow what you can do the day after tomorrow."
let quoteAuthor = "Mark Twain"
print("\(quoteText) — \(quoteAuthor)")
}
func applicationWillTerminate(_ aNotification: Notification) {
// Insert code here to tear down your application
}
}
Ожидание
![A picture of the icon](https://i.stack.imgur.com/kdQ9i.jpg)
Реальность
![A screenshot showing a black square for my icon alongside other status bar items](https://i.stack.imgur.com/sEE3U.png)