Dynamic: Catalyst NSStatusBar with NSStatusBar not working
Hi guys, I’ve tried to have the NSStatusBar working with a NSStatusBar on a project developed with React Native and Catalyst, but the icon doesn’t appear.
Here is the code, it compiles and the app runs successfully, but no icon appear on the top right corner of the screen
import UIKit
import Dynamic
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
var bridge: RCTBridge!
let statusItem = Dynamic.NSStatusBar.system.statusItem(withLength:Dynamic.NSStatusItem.squareLength)
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
let jsCodeLocation: URL
jsCodeLocation = RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index", fallbackResource:nil)
let rootView = RCTRootView(bundleURL: jsCodeLocation, moduleName: "myModule", initialProperties: nil, launchOptions: launchOptions)
let rootViewController = UIViewController()
rootViewController.view = rootView
self.window = UIWindow(frame: UIScreen.main.bounds)
self.window?.rootViewController = rootViewController
self.window?.makeKeyAndVisible()
statusItem.button.image = Dynamic.NSImage(named:Dynamic.NSImage.Name("iconbar"))
return true
}
}
Do you have any idea what I’m missing?
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 16 (2 by maintainers)
I usually check how it’s defined in the SDK headers. In Xcode, File -> Open Quickly… and type the constant name.
This is how
NSSquareStatusItemLength
is defined: