Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. import Foundation
  2.  
  3. import UIKit
  4.  
  5. class MySampleView :UIView{
  6. override init(frame: CGRect) {
  7. super.init(frame: frame)
  8. self.backgroundColor = UIColor.blue
  9. }
  10.  
  11. required init?(coder aDecoder: NSCoder) {
  12. fatalError("init(coder:) has not been implemented")
  13. }
  14. }
  15.  
  16. func createRNView(
  17. didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?
  18. ) -> UIView {
  19. let jsCodeLocation = RCTBundleURLProvider
  20. .sharedSettings()
  21. .jsBundleURL(
  22. forBundleRoot: "index.ios",
  23. fallbackResource:nil)
  24.  
  25. let rootView = RCTRootView(
  26. bundleURL: jsCodeLocation,
  27. moduleName: "mynativeejectapp",
  28. initialProperties: nil,
  29. launchOptions: launchOptions
  30. )
  31. return rootView!
  32. }
  33.  
  34. func createUIView(frame: CGRect) -> UIView {
  35. return MySampleView(frame: frame)
  36. }
  37.  
  38.  
  39. @UIApplicationMain
  40. class AppDelegate: UIResponder, UIApplicationDelegate {
  41. var window: UIWindow?
  42. var bridge: RCTBridge!
  43.  
  44. func application(
  45. _ application: UIApplication,
  46. didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?
  47. ) -> Bool {
  48. let rootViewController = UIViewController()
  49.  
  50.  
  51. // Create ReactNativeView as root
  52. // let rootView = createRNView(didFinishLaunchingWithOptions: launchOptions)
  53.  
  54. // Create ReactNativeView under root UIView
  55. let rootView = createUIView(frame: UIScreen.main.bounds)
  56. let rnView = createRNView(didFinishLaunchingWithOptions: launchOptions)
  57. rnView.frame = UIScreen.main.bounds
  58. rootView.addSubview(rnView)
  59. rootViewController.view = rootView
  60.  
  61. let window = UIWindow(frame: UIScreen.main.bounds)
  62. window.rootViewController = rootViewController
  63. window.makeKeyAndVisible()
  64. self.window = window
  65.  
  66. return true
  67. }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement