Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Foundation
- import UIKit
- class MySampleView :UIView{
- override init(frame: CGRect) {
- super.init(frame: frame)
- self.backgroundColor = UIColor.blue
- }
- required init?(coder aDecoder: NSCoder) {
- fatalError("init(coder:) has not been implemented")
- }
- }
- @UIApplicationMain
- class AppDelegate: UIResponder, UIApplicationDelegate {
- var window: UIWindow?
- var bridge: RCTBridge!
- func application(
- _ application: UIApplication,
- didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?
- ) -> Bool {
- let rootViewController = UIViewController()
- // Create ReactNativeView as root
- // let rootView = createRNView(didFinishLaunchingWithOptions: launchOptions)
- // Create iOS UIView as root
- let rootView = createUIView(frame: UIScreen.main.bounds)
- rootViewController.view = rootView
- let window = UIWindow(frame: UIScreen.main.bounds)
- window.rootViewController = rootViewController
- window.makeKeyAndVisible()
- self.window = window
- return true
- }
- func createRNView(
- didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?
- ) -> UIView {
- let jsCodeLocation = RCTBundleURLProvider
- .sharedSettings()
- .jsBundleURL(
- forBundleRoot: "index.ios",
- fallbackResource:nil)
- let rootView = RCTRootView(
- bundleURL: jsCodeLocation,
- moduleName: "mynativeejectapp",
- initialProperties: nil,
- launchOptions: launchOptions
- )
- return rootView!
- }
- func createUIView(frame: CGRect) -> UIView {
- return MySampleView(frame: frame)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement