Swift 海关;关于申请”;Mac Catalyst窗口
是否更改Mac Catalyst的“关于应用程序”窗口? 这是怎么做的?类似这样的事情:Swift 海关;关于申请”;Mac Catalyst窗口,swift,xcode,menuitem,mac-catalyst,Swift,Xcode,Menuitem,Mac Catalyst,是否更改Mac Catalyst的“关于应用程序”窗口? 这是怎么做的?类似这样的事情: #if targetEnvironment(macCatalyst) extension AppDelegate { override func buildMenu(with builder: UIMenuBuilder) { guard builder.system == .main else { return } // override about button builder
#if targetEnvironment(macCatalyst)
extension AppDelegate {
override func buildMenu(with builder: UIMenuBuilder) {
guard builder.system == .main else { return }
// override about button
builder.replaceChildren(ofMenu: .about) { (oldChildren) -> [UIMenuElement] in
let menuElement = oldChildren.first
if let uiCommand = menuElement as? UICommand {
let aboutUICommand = UICommand(title: uiCommand.title,
action: #selector(aboutApp(_:)))
return [aboutUICommand]
} else {
return oldChildren
}
}
}
override func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool {
return super.canPerformAction(action, withSender: sender)
}
override func target(forAction action: Selector, withSender sender: Any?) -> Any? {
if action == #selector(aboutApp) {
return self
} else {
return nil
}
}
@objc func aboutApp(_ selector: Any?) {
guard let aboutTVC = AboutViewController.createInstance() else { return; }
rootViewController?.present(aboutTVC, animated: true, completion: nil)
}
}
#endif
非常感谢!我成功地将About菜单项链接到一个模态视图。是否也可以将About视图作为一个单独的窗口(“应用程序窗口外”)获取?标准的“关于窗口”与“应用程序”菜单是分开的。是的,但您需要为应用程序启用多窗口,并使用uiscenedelegate来管理窗口