【发布时间】:2016-12-27 04:42:47
【问题描述】:
我想在用户从默认模式切换到暗模式时更改我的状态栏应用程序图标,反之亦然(使用 Swift 3)。这是我目前所拥有的:
func applicationDidFinishLaunching(_ aNotification: Notification) {
DistributedNotificationCenter.default().addObserver(self, selector: #selector(darkModeChanged(sender:)), name: "AppleInterfaceThemeChangedNotification", object: nil)
}
...
func darkModeChanged(sender: NSNotification) {
print("mode changed")
}
不幸的是,它不起作用。我做错了什么?
【问题讨论】:
标签: swift selector nsnotificationcenter observers nsdistributednotification