我正在构建一个非常简单的菜单栏应用程序,它仅告诉我星期数,这非常简单,我遵循了基础教程来制作一个简单的应用程序和一个图标,等等,我尝试了使用图标,不使用和对齐方式没有什么不同。
如何向下推以使其更对齐?或调整文字大小?
这纯粹是美学,因为它使我发疯,无法找到明确的解释。
任何帮助或指导点将不胜感激:)
我当前的代码仅仅是(不显示我没有使用过的任何东西):
class AppDelegate: NSObject, NSApplicationDelegate {
let statusItem = NSStatusBar.system.statusItem(withLength:NSStatusItem.variableLength)
func applicationDidFinishLaunching(_ aNotification: Notification) {
// Insert code here to initialize your application
var helloWorldTimer = Timer.scheduledTimer(
timeInterval: 1,
target: self,
selector: #selector(AppDelegate.updateWeekNumber(_:)),
userInfo: nil,
repeats: true
)
}
@objc func updateWeekNumber(_ sender: Any?) {
let date = Date()
let calendar = Calendar.current
let weekOfYear = calendar.component(.weekOfYear, from: date)
let btnText = String(format: " Week %02d", weekOfYear)
if let button = statusItem.button {
button.image = NSImage(named:NSImage.Name("CalendarImageButton"))
button.imagePosition = NSControl.ImagePosition.imageLeft
//button.action = #selector(printQuote(_:))
button.title = btnText
}
}
}